Merge lp:~mallorymarcot/unifield-server/us-3684 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4723
Proposed branch: lp:~mallorymarcot/unifield-server/us-3684
Merge into: lp:unifield-server
Diff against target: 80 lines (+45/-7)
1 file modified
bin/addons/supplier_catalogue/supplier_catalogue.py (+45/-7)
To merge this branch: bzr merge lp:~mallorymarcot/unifield-server/us-3684
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+336241@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/supplier_catalogue/supplier_catalogue.py'
2--- bin/addons/supplier_catalogue/supplier_catalogue.py 2017-08-23 21:01:21 +0000
3+++ bin/addons/supplier_catalogue/supplier_catalogue.py 2018-02-01 10:38:24 +0000
4@@ -204,6 +204,30 @@
5
6 return res
7
8+
9+ def unlink(self, cr, uid, ids, context=None):
10+ if isinstance(ids, (int, long)):
11+ ids = [ids]
12+ if context is None:
13+ context = {}
14+
15+ entity_identifier = self.pool.get('sync.client.entity').get_entity(cr, uid, context).identifier
16+
17+ # forbid supplier catalogue coming from higher instance level to be manually deleted:
18+ to_unlink = set()
19+ for catalogue in self.browse(cr, uid, ids, context=context):
20+ catalogue_sd_ref = self.get_sd_ref(cr, uid, catalogue.id)
21+ if catalogue_sd_ref and catalogue_sd_ref.startswith(entity_identifier) or context.get('sync_update_execution', False):
22+ to_unlink.add(catalogue.id)
23+ else:
24+ raise osv.except_osv(
25+ _('Error'),
26+ _('Warning! You cannot delete a synched supplier catalogue created in a higher instance level.')
27+ )
28+
29+ return super(supplier_catalogue, self).unlink(cr, uid, list(to_unlink), context=context)
30+
31+
32 def write(self, cr, uid, ids, vals, context=None):
33 '''
34 Update the supplierinfo and pricelist line according to the
35@@ -1027,16 +1051,30 @@
36
37 return res
38
39- def unlink(self, cr, uid, line_id, context=None):
40+ def unlink(self, cr, uid, ids, context=None):
41 '''
42 Remove the pricelist line on product supplier information tab
43 If the product supplier information has no line, remove it
44 '''
45- if isinstance(line_id, (int, long)):
46- line_id = [line_id]
47-
48- for l in line_id:
49- line = self.browse(cr, uid, l, context=context)
50+ if isinstance(ids, (int, long)):
51+ ids = [ids]
52+
53+ entity_identifier = self.pool.get('sync.client.entity').get_entity(cr, uid, context).identifier
54+
55+ # forbid supplier catalogue line coming from higher instance level to be manually deleted:
56+ to_unlink = set()
57+ for cat_line in self.browse(cr, uid, ids, context=context):
58+ cat_line_sd_ref = self.get_sd_ref(cr, uid, cat_line.id)
59+ if cat_line_sd_ref and cat_line_sd_ref.startswith(entity_identifier) or context.get('sync_update_execution', False):
60+ to_unlink.add(cat_line.id)
61+ else:
62+ raise osv.except_osv(
63+ _('Error'),
64+ _('Warning! You cannot delete a synched supplier catalogue line created in a higher instance level.')
65+ )
66+ to_unlink = list(to_unlink)
67+
68+ for line in self.browse(cr, uid, to_unlink, context=context):
69 c = context is not None and context.copy() or {}
70 c.update({'product_change': True})
71 # Remove the pricelist line in product tab
72@@ -1048,7 +1086,7 @@
73 # Remove the supplier info
74 self.pool.get('product.supplierinfo').unlink(cr, uid, line.supplier_info_id.id, context=c)
75
76- return super(supplier_catalogue_line, self).unlink(cr, uid, line_id, context=context)
77+ return super(supplier_catalogue_line, self).unlink(cr, uid, to_unlink, context=context)
78
79 def _check_min_quantity(self, cr, uid, ids, context=None):
80 '''

Subscribers

People subscribed via source and target branches