← Back to team overview

openerp-connector-community team mailing list archive

Re: Binding Models integrity

 

Glad to know there are no restrictions.
I am in fact writing an export_synchroniser ..
Now I suppose it will take to adapt the binder to be able to set/distinguish which external record is to be updated according to the actual user and partner. (to_backend(), bin(), etc)

Thanks for your help.
Nicolas

> On 1 oct. 2015, at 12:17, Guewen Baconnier <guewen.baconnier@xxxxxxxxxxxxxx> wrote:
> 
> On Thu, Oct 1, 2015 at 11:58 AM, Nicolas Clavier <nicoclavier@xxxxxxxxx <mailto:nicoclavier@xxxxxxxxx>> wrote:
> Hi folks, 
> 
> In a scenario, users synchronise odoo partners with external records that are unique to the user on an backend.
> 
> I’m willing to maintain a unique relationship between :
> - a user (user_id > res.users)
> - a partner (openerp_id > res.partner)
> - an external record (external_id)
> 
> all this on :
> - a backend record (backend_id)
> 
>  I should override the abstract binding model’s _sql_constraints in the inheriting concrete binding model (and probably proceed as per advised in the following article <http://ludwiktrammer.github.io/odoo/changing-sql-constraints-child-models-odoo-8.html> for odoo 8.0) to come up with something like :
> 
> class Foo(models.Model):
> 	_inherit = ‘external.binding'
> 	# ...
> 	_sql_constraints = [
> 		(‘external_uniq', 'unique(backend_id, external_id, user_id)', 'A binding already exists with the same external ID for the same User ')
> 	]
>     
> 	def _auto_init(self, cr, context=None):
> 		self._sql_constraints = self._sql_constraints.reverse()
> 		super(Foo, self)._auto_init(cr, context)
> 
> My Questions are : 
> - Are there obvious issues preventing to establish a sort of “many2many” link in the external.binding between 1 openerp_id and several external_id’s
> - Any recommendations ?
> 
> Thanks for your advises.
> Nicolas Clavier
> <IMG_1451.jpeg>
> 
> Hi,
> 
> There are no enforced rule in the connector that a binding should be unique for one record and one backend.
> This rule is enforced in the Magento connector for this reason: if you have 2 different bindings on Odoo for one Magento record, the export of the bindings to Magento would be quite undeterministic (both records would want to export their own values on the same Magento records).
> 
> Now if you know that you will never export the records to the backend, I see no reason to forbid that. 
> Unless you are extending the Magento connector, you won't have any constraint to disable because there is none in the connector core:https://github.com/OCA/connector/blob/8.0/connector/backend_model.py#L118-L122 <https://github.com/OCA/connector/blob/8.0/connector/backend_model.py#L118-L122>
> 
> -- 
> Guewen Baconnier
> Business Solutions Software Developer
> 
> Camptocamp SA
> PSE A, CH-1015 Lausanne
> Phone: +41 21 619 10 39
> Office: +41 21 619 10 10
> http://www.camptocamp.com/ <http://www.camptocamp.com/> 
> 


References