Merge lp:~unifield-team/unifield-server/us-1492 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3938
Proposed branch: lp:~unifield-team/unifield-server/us-1492
Merge into: lp:unifield-server
Diff against target: 202 lines (+105/-29)
3 files modified
bin/addons/supplier_catalogue/partner_view.xml (+19/-12)
bin/addons/supplier_catalogue/supplier_catalogue.py (+85/-16)
bin/addons/supplier_catalogue/supplier_catalogue_view.xml (+1/-1)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-1492
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+303573@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
=== modified file 'bin/addons/supplier_catalogue/partner_view.xml'
--- bin/addons/supplier_catalogue/partner_view.xml 2013-02-13 06:50:09 +0000
+++ bin/addons/supplier_catalogue/partner_view.xml 2016-08-22 14:53:53 +0000
@@ -28,19 +28,26 @@
28 </data>28 </data>
29 </field>29 </field>
30 </record>30 </record>
31 31
32 <delete id="action_new_catalogue_supplier" model="ir.actions.act_window" />
33 <record id="action_create_new_catalogue" model="ir.actions.server">
34 <field name="name">New Catalogue</field>
35 <field name="model_id" ref="model_supplier_catalogue"/>
36 <field name="state">code</field>
37 <field name="code">action = obj.open_new_catalogue_form(context=context)</field>
38 </record>
39
32 <!-- Action to create a new catalogue for this supplier -->40 <!-- Action to create a new catalogue for this supplier -->
33 <act_window41 <record id="action_new_catalogue_supplier2" model="ir.values">
34 name="New catalogue"42 <field name="key2">client_action_multi</field>
35 res_model="supplier.catalogue"43 <field name="model">res.partner</field>
36 src_model="res.partner"44 <field name="name">New catalogue</field>
37 view_mode="form,tree"45 <field eval="'ir.actions.server,%d'%action_create_new_catalogue" name="value"/>
38 view_type="form"46 <field name="context">{'partner_id': active_id}</field>
39 key2="client_action_multi"47 <field name="sequence" eval="1" />
40 domain="[('partner_id', '=', active_id)]"48 <field eval="True" name="object"/>
41 context="{'partner_id': active_id}"49 </record>
42 id="action_new_catalogue_supplier" />50
43
44 <!-- Choose catalogue from supplier (osv_memory) form view -->51 <!-- Choose catalogue from supplier (osv_memory) form view -->
45 <record id="from_supplier_choose_catalogue_form_view" model="ir.ui.view">52 <record id="from_supplier_choose_catalogue_form_view" model="ir.ui.view">
46 <field name="name">from.supplier.choose.catalogue.form.view</field>53 <field name="name">from.supplier.choose.catalogue.form.view</field>
4754
=== modified file 'bin/addons/supplier_catalogue/supplier_catalogue.py'
--- bin/addons/supplier_catalogue/supplier_catalogue.py 2016-04-29 07:39:24 +0000
+++ bin/addons/supplier_catalogue/supplier_catalogue.py 2016-08-22 14:53:53 +0000
@@ -58,6 +58,33 @@
5858
59 return False59 return False
6060
61 def open_new_catalogue_form(self, cr, uid, ids, context=None):
62 if context is None:
63 context = {}
64 context['partner_id'] = ids[0]
65 partner_obj = self.pool.get('res.partner')
66 if partner_obj.search(cr, uid, [('id', '=', ids[0]), ('partner_type', '=', 'esc')], context=context):
67 user = self.pool.get('res.users').browse(cr, uid, uid,context=context)
68 level = user and user.company_id and user.company_id.instance_id and user.company_id.instance_id.level or False
69 if level != 'section':
70 raise osv.except_osv(
71 _('Error'),
72 'For an ESC Supplier you must create the catalogue on a HQ instance.'
73 )
74 elif self.search(cr, uid, [('active', '=', True), ('partner_id', '=', ids[0])]):
75 raise osv.except_osv(
76 _('Error'),
77 _('Warning! There is already another active catalogue for this Supplier! This could have implications on the synching of catalogue to instances below, please check.'),
78 )
79
80 return {
81 'res_model': 'supplier.catalogue',
82 'view_type': 'form',
83 'view_mode': 'form,tree',
84 'type': 'ir.actions.act_window',
85 'context': context,
86 'domain': [('partner_id', '=', ids[0])],
87 }
61 def _update_other_catalogue(self, cr, uid, cat_id, period_from, currency_id, partner_id, period_to=False, context=None):88 def _update_other_catalogue(self, cr, uid, cat_id, period_from, currency_id, partner_id, period_to=False, context=None):
62 '''89 '''
63 Check if other catalogues with the same partner/currency exist and are defined in the period of the90 Check if other catalogues with the same partner/currency exist and are defined in the period of the
@@ -83,21 +110,6 @@
83 order='period_from asc',110 order='period_from asc',
84 limit=1,111 limit=1,
85 context=context)112 context=context)
86 if period_to:
87 to_ids = self.search(cr, uid, [('id', 'not in', context.get('cat_ids', [])), ('period_from', '>', period_from),
88 ('period_from', '<', period_to),
89 ('currency_id', '=', currency_id),
90 ('partner_id', '=', partner_id)],
91 order='period_from asc',
92 limit=1,
93 context=context)
94 else:
95 to_ids = self.search(cr, uid, [('id', 'not in', context.get('cat_ids', [])), ('period_from', '>', period_from),
96 ('currency_id', '=', currency_id),
97 ('partner_id', '=', partner_id)],
98 order='period_from asc',
99 limit=1,
100 context=context)
101113
102 # If overrided catalogues exist, display an error message114 # If overrided catalogues exist, display an error message
103 if equal_ids:115 if equal_ids:
@@ -111,6 +123,30 @@
111 raise osv.except_osv(_('Error'), _('This catalogue has the same \'From\' date than the following catalogue : %s (\'From\' : %s - \'To\' : %s) - ' \123 raise osv.except_osv(_('Error'), _('This catalogue has the same \'From\' date than the following catalogue : %s (\'From\' : %s - \'To\' : %s) - ' \
112 'Please change the \'From\' date of this new catalogue or delete the other catalogue.') % (over_cat.name, over_cat_from, over_cat_to))124 'Please change the \'From\' date of this new catalogue or delete the other catalogue.') % (over_cat.name, over_cat_from, over_cat_to))
113125
126 elif cat and cat.is_esc:
127 raise osv.except_osv(
128 _('Error'),
129 _('Warning! There is already another active catalogue for this Supplier! This could have implications on the synching of catalogue to instances below, please check.'),
130 )
131
132 if period_to:
133 to_ids = self.search(cr, uid,
134 [('id', 'not in', context.get('cat_ids', [])), ('period_from', '>', period_from),
135 ('period_from', '<', period_to),
136 ('currency_id', '=', currency_id),
137 ('partner_id', '=', partner_id)],
138 order='period_from asc',
139 limit=1,
140 context=context)
141 else:
142 to_ids = self.search(cr, uid,
143 [('id', 'not in', context.get('cat_ids', [])), ('period_from', '>', period_from),
144 ('currency_id', '=', currency_id),
145 ('partner_id', '=', partner_id)],
146 order='period_from asc',
147 limit=1,
148 context=context)
149
114 # If overrided catalogues exist, display an error message150 # If overrided catalogues exist, display an error message
115 if to_ids:151 if to_ids:
116 over_cat = self.browse(cr, uid, to_ids[0], context=context)152 over_cat = self.browse(cr, uid, to_ids[0], context=context)
@@ -159,6 +195,12 @@
159 catalogue = self.browse(cr, uid, [res], context=context)[0]195 catalogue = self.browse(cr, uid, [res], context=context)[0]
160 if not catalogue.partner_id.active:196 if not catalogue.partner_id.active:
161 self.write(cr, uid, [res], {'active': False}, context=context)197 self.write(cr, uid, [res], {'active': False}, context=context)
198 elif not context.get('sync_update_execution') and vals.get('active') and catalogue.partner_id.partner_type == 'esc':
199 if self.search(cr, uid, [('partner_id', '=', catalogue.partner_id.id), ('active', '=', True)], count=True, context=context) > 1:
200 raise osv.except_osv(
201 _('Error'),
202 _('Warning! There is already another active catalogue for this Supplier! This could have implications on the synching of catalogue to instances below, please check.'),
203 )
162204
163 return res205 return res
164206
@@ -255,6 +297,33 @@
255297
256 return True298 return True
257299
300 def check_inactive_catalogues(self, cr, uid, ids, partner_id, context=None):
301 '''
302 Check if there are an inactive catalogue for this supplier. If yes, display a warning messagse
303 '''
304 res = {}
305
306 if not ids:
307 ids = []
308
309 if partner_id and self.pool.get('res.partner').read(cr, uid, partner_id, ['partner_type'], context=context)['partner_type'] == 'esc':
310 equal_ids = self.search(cr, uid, [
311 ('id', 'not in', ids),
312 ('active', '=', False),
313 ('partner_id', '=', partner_id),
314 ], order='period_from asc', limit=1, context=context)
315 if equal_ids:
316 res.update({
317 'warning': {
318 'title': _('Warning'),
319 'message': _('Warning! There is already another inactive catalogue for this Supplier! This could have implications on the synching of catalogue to instances below, please check'),
320 },
321 })
322
323
324
325 return res
326
258 def button_draft(self, cr, uid, ids, context=None):327 def button_draft(self, cr, uid, ids, context=None):
259 '''328 '''
260 Reset to draft the catalogue329 Reset to draft the catalogue
@@ -375,7 +444,7 @@
375 _columns = {444 _columns = {
376 'name': fields.char(size=64, string='Name', required=True),445 'name': fields.char(size=64, string='Name', required=True),
377 'partner_id': fields.many2one('res.partner', string='Partner', required=True,446 'partner_id': fields.many2one('res.partner', string='Partner', required=True,
378 domain=[('supplier', '=', True)]),447 domain=[('supplier', '=', True)], select=1),
379 'period_from': fields.date(string='From',448 'period_from': fields.date(string='From',
380 help='Starting date of the catalogue.'),449 help='Starting date of the catalogue.'),
381 'period_to': fields.date(string='To',450 'period_to': fields.date(string='To',
382451
=== modified file 'bin/addons/supplier_catalogue/supplier_catalogue_view.xml'
--- bin/addons/supplier_catalogue/supplier_catalogue_view.xml 2016-03-31 08:47:35 +0000
+++ bin/addons/supplier_catalogue/supplier_catalogue_view.xml 2016-08-22 14:53:53 +0000
@@ -31,7 +31,7 @@
31 <field name="type">form</field>31 <field name="type">form</field>
32 <field name="arch" type="xml">32 <field name="arch" type="xml">
33 <form string="Supplier catalogue">33 <form string="Supplier catalogue">
34 <field name="name" colspan="4" />34 <field name="name" colspan="4" on_change="check_inactive_catalogues(partner_id)" />
35 <field name="period_from" attrs="{'required': [('is_esc', '=', False)], 'invisible': [('is_esc', '=', True)]}" />35 <field name="period_from" attrs="{'required': [('is_esc', '=', False)], 'invisible': [('is_esc', '=', True)]}" />
36 <field name="period_to" attrs="{'invisible': [('is_esc', '=', True)]}" />36 <field name="period_to" attrs="{'invisible': [('is_esc', '=', True)]}" />
37 <field name="currency_id" domain="[('partner_currency', '=', partner_id)]" />37 <field name="currency_id" domain="[('partner_currency', '=', partner_id)]" />

Subscribers

People subscribed via source and target branches

to all changes: