Merge lp:~jfb-tempo-consulting/unifield-server/us-636 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5150
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/us-636
Merge into: lp:unifield-server
Diff against target: 230 lines (+48/-36)
6 files modified
bin/addons/msf_partner/partner.py (+20/-18)
bin/addons/msf_sync_data_server/data/sync_server.message_rule.csv (+1/-1)
bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv (+1/-1)
bin/addons/supplier_catalogue/product.py (+15/-15)
bin/addons/sync_so/sale.py (+6/-0)
bin/addons/sync_so/so_po_common.py (+5/-1)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/us-636
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+354928@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/msf_partner/partner.py'
2--- bin/addons/msf_partner/partner.py 2018-07-30 14:02:59 +0000
3+++ bin/addons/msf_partner/partner.py 2018-09-14 08:02:39 +0000
4@@ -406,26 +406,10 @@
5
6 bro = bro_uid.company_id
7 res = bro and bro.partner_id and bro.partner_id.id
8- cur = bro and bro.currency_id and bro.currency_id.id
9-
10- po_def_cur = self.pool.get('product.pricelist').browse(cr,uid,vals.get('property_product_pricelist_purchase'))
11- fo_def_cur = self.pool.get('product.pricelist').browse(cr,uid,vals.get('property_product_pricelist'))
12
13 if res in ids:
14 for obj in self.browse(cr, uid, [res], context=context):
15
16- if context.get('from_setup') and bro.second_time and po_def_cur and po_def_cur.currency_id and po_def_cur.currency_id.id != cur:
17- raise osv.except_osv(_('Warning !'), _('You can not change the Purchase Default Currency of this partner anymore'))
18-
19- if not context.get('from_setup') and po_def_cur and po_def_cur.currency_id and po_def_cur.currency_id.id != cur:
20- raise osv.except_osv(_('Warning !'), _('You can not change the Purchase Default Currency of this partner'))
21-
22- if context.get('from_setup') and bro.second_time and fo_def_cur and fo_def_cur.currency_id and fo_def_cur.currency_id.id != cur:
23- raise osv.except_osv(_('Warning !'), _('You can not change the Field Orders Default Currency of this partner anymore'))
24-
25- if not context.get('from_setup') and fo_def_cur and fo_def_cur.currency_id and fo_def_cur.currency_id.id != cur:
26- raise osv.except_osv(_('Warning !'), _('You can not change the Field Orders Default Currency of this partner'))
27-
28 if obj.customer:
29 raise osv.except_osv(_('Warning !'), _('This partner can not be checked as customer'))
30
31@@ -649,6 +633,22 @@
32 payable_acc = account_obj.browse(cr, uid, vals['property_account_payable'], fields_to_fetch=['code', 'name'], context=context)
33 raise osv.except_osv(_('Error'), _('The account %s - %s cannot be used as Account Payable.') % (payable_acc.code, payable_acc.name))
34
35+ def check_same_pricelist(self, cr, uid, ids, context=None):
36+ if context is None:
37+ context = {}
38+
39+ if context.get('sync_update_execution'):
40+ return True
41+
42+
43+ for x in self.browse(cr, uid, ids, fields_to_fetch=['property_product_pricelist_purchase', 'property_product_pricelist', 'name'], context=context):
44+ if x.property_product_pricelist_purchase.currency_id.id != x.property_product_pricelist.currency_id.id:
45+ raise osv.except_osv(_('Warning'),
46+ _('Partner %s : Purchase Default Currency (%s) and Field Orders Default Currency (%s) must be the same') % (x.name, x.property_product_pricelist_purchase.currency_id.name, x.property_product_pricelist.currency_id.name)
47+ )
48+
49+ return True
50+
51 def write(self, cr, uid, ids, vals, context=None):
52 if not ids:
53 return True
54@@ -686,7 +686,9 @@
55 if vals.get('name'):
56 vals['name'] = vals['name'].replace('\r\n', ' ').replace('\r', ' ').replace('\n', ' ').strip()
57
58- return super(res_partner, self).write(cr, uid, ids, vals, context=context)
59+ ret = super(res_partner, self).write(cr, uid, ids, vals, context=context)
60+ self.check_same_pricelist(cr, uid, ids, context=context)
61+ return ret
62
63 def create(self, cr, uid, vals, context=None):
64 fields_to_create = vals.keys()
65@@ -721,7 +723,7 @@
66
67 new_id = super(res_partner, self).create(cr, uid, vals, context=context)
68 self.check_partner_unicity(cr, uid, partner_id=new_id, context=context)
69-
70+ self.check_same_pricelist(cr, uid, [new_id], context=context)
71 # US-3945: checking user's rights
72 if not context.get('sync_update_execution') and uid != 1:
73 instance_level = _get_instance_level(self, cr, uid)
74
75=== modified file 'bin/addons/msf_sync_data_server/data/sync_server.message_rule.csv'
76--- bin/addons/msf_sync_data_server/data/sync_server.message_rule.csv 2018-08-14 10:33:11 +0000
77+++ bin/addons/msf_sync_data_server/data/sync_server.message_rule.csv 2018-09-14 08:02:39 +0000
78@@ -1,6 +1,6 @@
79 id,active,applies_to_type,arguments,domain,destination_name,type_id,remote_call,model_id,name,sequence_number,wait_while,status
80 msf_sync_data_server.resourcing_lines,TRUE,TRUE,"['sync_order_line_db_id', 'partner_id', 'resource_ok', 'resource_sync_line_db_id', 'partner_type']","[('partner_type','!=','external'), ('partner_id', '!=', False)]",partner_id,MISSION,sale.order.line.cancel.create_line,sale.order.line.cancel,Resourcing lines,1,,Valid
81-msf_sync_data_server.po_creates_fo,TRUE,TRUE,"['name', 'analytic_distribution_id/id', 'delivery_requested_date','details','notes', 'origin', 'categ', 'order_type', 'priority', 'loan_duration', 'is_a_counterpart', 'sourced_references', 'stock_take_date']","['&','&','&',('partner_type','not in',['external','esc']),('state','in',['validated','validated_p','sourced_p','confirmed','confirmed_p']), ('split_po','!=','True'),('push_fo','!=','True')]",partner_id,MISSION,sale.order.create_so,purchase.order,PO creates FO,2,,Valid
82+msf_sync_data_server.po_creates_fo,TRUE,TRUE,"['name', 'analytic_distribution_id/id', 'delivery_requested_date','details','notes', 'origin', 'categ', 'order_type', 'priority', 'loan_duration', 'is_a_counterpart', 'sourced_references', 'stock_take_date', 'currency_id/id']","['&','&','&',('partner_type','not in',['external','esc']),('state','in',['validated','validated_p','sourced_p','confirmed','confirmed_p']), ('split_po','!=','True'),('push_fo','!=','True')]",partner_id,MISSION,sale.order.create_so,purchase.order,PO creates FO,2,,Valid
83 msf_sync_data_server.normal_fo_creates_po,TRUE,TRUE,"['name','state','analytic_distribution_id/id','parent_order_name','delivery_confirmed_date','est_transport_lead_time', 'categ', 'order_type', 'priority', 'loan_duration','transport_type', 'ready_to_ship_date', 'details', 'note','client_order_ref', 'stock_take_date', 'order_line/product_id/id', 'order_line/product_id/name','order_line/id', 'order_line/name', 'order_line/product_uom_qty', 'order_line/product_uom', 'order_line/price_unit', 'order_line/analytic_distribution_id/id','order_line/comment','order_line/have_analytic_distribution_from_header','order_line/line_number', 'order_line/nomen_manda_0/id','order_line/nomen_manda_1/id','order_line/nomen_manda_2/id','order_line/nomen_manda_3/id', 'order_line/sync_order_line_db_id', 'order_line/nomenclature_description','order_line/notes','order_line/default_name','order_line/default_code','order_line/date_planned', 'order_line/confirmed_delivery_date', 'order_line/stock_take_date']","[('partner_type','!=','external'),('state','not in',['draft','draft_p']),('client_order_ref','=',False)]",partner_id,MISSION,purchase.order.normal_fo_create_po,sale.order,Normal FO creates PO,5,,Valid
84 msf_sync_data_server.po_updates_so_ref,TRUE,TRUE,"['name','state','partner_ref']","['&','&','&',('partner_type','!=','external'),('state','in',['validated', 'validated_p', 'sourced', 'sourced_p', 'confirmed', 'confirmed_p']),('partner_ref','!=',False),'!',('partner_ref', 'like', 'invalid_by_recovery')]",partner_id,MISSION,sale.order.update_sub_so_ref,purchase.order,PO updates SO ref,8,,Valid
85 msf_sync_data_server.fo_updates_po_ref,TRUE,TRUE,"['name','state','client_order_ref']","['&', '&','&','&', ('claim_name_goods_return', '=', False), ('partner_type','!=','external'),('client_order_ref','!=',False),('split_type_sale_order','=','original_sale_order'),'!',('client_order_ref', 'like', 'invalid_by_recovery')]",partner_id,MISSION,purchase.order.update_fo_ref,sale.order,FO updates PO ref,9,,Valid
86
87=== modified file 'bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv'
88--- bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv 2018-08-21 19:12:31 +0000
89+++ bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv 2018-09-14 08:02:39 +0000
90@@ -56,7 +56,7 @@
91 msf_sync_data_server.external_partner,TRUE,TRUE,FALSE,TRUE,bidirectional,Bidirectional,"[('partner_type' , '=' , 'external'),('name','!=','Local Market')]","['name', 'partner_type', 'property_account_receivable/id', 'property_account_payable/id', 'ref', 'customer','supplier','zone', 'lang', 'property_product_pricelist/id', 'property_product_pricelist_purchase/id', 'donation_payable_account/id']",HQ + MISSION,res.partner,,External Partner,Valid,"{'active':False}",309
92 msf_sync_data_server.external_partner_tree,TRUE,TRUE,FALSE,TRUE,bidirectional,Bidirectional,"[('partner_type' , '=' , 'external'),('name','!=','Local Market'), ('parent_id', '!=', '')]",['parent_id/id'],HQ + MISSION,res.partner,,External Partner Tree,Valid,,310
93 msf_sync_data_server.external_partner_address,TRUE,TRUE,FALSE,TRUE,bidirectional,Bidirectional,"['|', ('active', '=', ''), ('active', '!=', ''),('partner_id' , 'in' , ('res.partner' , 'id' , [('partner_type' , '=' , 'external')]))]","['active', 'city', 'country_id/id', 'email', 'fax', 'function', 'mobile', 'name', 'partner_id/id', 'phone', 'state_id/id', 'street', 'street2', 'title/id', 'type', 'zip']",HQ + MISSION,res.partner.address,,External Partner Address,Valid,,311
94-msf_sync_data_server.internal_partner,TRUE,TRUE,FALSE,TRUE,bidirectional,Bidirectional,"['|', ('active', '=', ''), ('active', '!=', ''),('partner_type' , '=' , 'internal')]","['comment', 'credit_limit', 'customer', 'customer_lt', 'lang', 'manufacturer', 'name', 'partner_type', 'po_by_project', 'procurement_lt', 'property_account_payable/id', 'property_account_position/id', 'property_account_receivable/id', 'property_payment_term/id', 'property_stock_customer/id', 'property_stock_supplier/id', 'ref', 'supplier', 'supplier_lt', 'transport_0', 'transport_0_lt', 'transport_1', 'transport_1_lt', 'transport_2', 'transport_2_lt', 'transporter']",MISSION,res.partner,,Internal Partner,Valid,"{'active': True, 'customer': True, 'supplier': True, 'partner_type': 'internal'}",312
95+msf_sync_data_server.internal_partner,TRUE,TRUE,FALSE,TRUE,bidirectional,Bidirectional,"['|', ('active', '=', ''), ('active', '!=', ''),('partner_type' , '=' , 'internal')]","['comment', 'credit_limit', 'customer', 'customer_lt', 'lang', 'manufacturer', 'name', 'partner_type', 'po_by_project', 'procurement_lt', 'property_account_payable/id', 'property_account_position/id', 'property_account_receivable/id', 'property_payment_term/id', 'property_stock_customer/id', 'property_stock_supplier/id', 'ref', 'supplier', 'supplier_lt', 'transport_0', 'transport_0_lt', 'transport_1', 'transport_1_lt', 'transport_2', 'transport_2_lt', 'transporter', 'property_product_pricelist/id', 'property_product_pricelist_purchase/id']",MISSION,res.partner,,Internal Partner,Valid,"{'active': True, 'customer': True, 'supplier': True, 'partner_type': 'internal'}",312
96 msf_sync_data_server.internal_partner_tree,TRUE,TRUE,FALSE,TRUE,bidirectional,Bidirectional,"['|', ('active', '=', ''), ('active', '!=', ''),('partner_type' , '=' , 'internal'), ('parent_id', '!=', '')]",['parent_id/id'],MISSION,res.partner,,Internal Partner Tree,Valid,,313
97 msf_sync_data_server.internal_partner_address,TRUE,TRUE,FALSE,TRUE,bidirectional,Bidirectional,"['|', ('active', '=', ''), ('active', '!=', ''),('partner_id' , 'in' , ('res.partner' , 'id' , [('partner_type' , '=' , 'internal')]))]","['active', 'city', 'country_id/id', 'email', 'fax', 'function', 'mobile', 'name', 'partner_id/id', 'phone', 'state_id/id', 'street', 'street2', 'title/id', 'type', 'zip']",MISSION,res.partner.address,,Internal Partner Address,Valid,,314
98 msf_sync_data_server.intermission_partner,TRUE,TRUE,FALSE,TRUE,bidirectional,Down,"['|', ('active', '=', ''), ('active', '!=', ''),('partner_type' , '=' , 'intermission')]","['customer', 'manufacturer', 'name', 'partner_type', 'property_account_payable/id', 'property_account_receivable/id', 'ref', 'supplier', 'transporter']",OC,res.partner,,Intermission Partner,Valid,"{'customer': True, 'supplier': True, 'active': False}",320
99
100=== modified file 'bin/addons/supplier_catalogue/product.py'
101--- bin/addons/supplier_catalogue/product.py 2017-09-28 15:51:02 +0000
102+++ bin/addons/supplier_catalogue/product.py 2018-09-14 08:02:39 +0000
103@@ -56,7 +56,7 @@
104 if not context:
105 context = {}
106
107- new_res = []
108+ new_res = []
109 res = super(product_supplierinfo, self).search(cr, uid, args, offset, limit,
110 order, context=context, count=count)
111 if count:
112@@ -326,7 +326,7 @@
113 # info = partner_price.browse(cr, uid, info_price, context=context)[0]
114 info = partner_price.browse(cr, uid, info_prices[0], context=context)
115 price = cur_obj.compute(cr, uid, info.currency_id.id, currency_id, info.price, round=False, context=context)
116- res[product.id] = (price, info.rounding or 1.00, info.suppinfo_id.min_qty or 0.00)
117+ res[product.id] = (price, info.rounding or 1.00, info.suppinfo_id.min_qty or 0.00)
118 else:
119 res[product.id] = (False, 1.0, 1.0)
120
121@@ -423,7 +423,7 @@
122 '''
123 Returns pricelists according to partner type
124 '''
125- user_obj = self.pool.get('res.users')
126+ #user_obj = self.pool.get('res.users')
127 cur_obj = self.pool.get('res.currency')
128 dom = []
129
130@@ -432,13 +432,13 @@
131 if arg[1] != '=':
132 raise osv.except_osv(_('Error !'), _('Bad operator !'))
133 else:
134- if arg[2] in ('internal', 'intermission'):
135- func_currency_id = user_obj.browse(cr, uid, uid, context=context).company_id.currency_id.id
136- dom.append(('currency_id', '=', func_currency_id))
137- elif arg[2] == 'section':
138- currency_ids = cur_obj.search(cr, uid, [('is_section_currency', '=', True)])
139- dom.append(('currency_id', 'in', currency_ids))
140- elif arg[2] == 'esc':
141+ #if arg[2] in ('internal', 'intermission'):
142+ # func_currency_id = user_obj.browse(cr, uid, uid, context=context).company_id.currency_id.id
143+ # dom.append(('currency_id', '=', func_currency_id))
144+ #if arg[2] == 'section':
145+ # currency_ids = cur_obj.search(cr, uid, [('is_section_currency', '=', True)])
146+ # dom.append(('currency_id', 'in', currency_ids))
147+ if arg[2] == 'esc':
148 currency_ids = cur_obj.search(cr, uid, [('is_esc_currency', '=', True)])
149 dom.append(('currency_id', 'in', currency_ids))
150
151@@ -447,7 +447,7 @@
152 def _get_currency_name(self, cr, uid, ids, field_name, args, context=None):
153 '''
154 Return the name of the related currency
155- '''
156+ '''
157 res = {}
158
159 for p_list in self.browse(cr, uid, ids, context=context):
160@@ -521,7 +521,7 @@
161 [('name', operator, name)], order='NO_ORDER', context=context)
162 ids = self.search(cr, uid, [('currency_id', 'in', currency_ids)] + (args or []))
163
164- return self.name_get(cr, uid, ids)
165+ return self.name_get(cr, uid, ids)
166
167
168 product_pricelist()
169@@ -585,9 +585,9 @@
170 return dom
171
172 _columns = {
173- 'is_section_currency': fields.boolean(string='Functional currency',
174+ 'is_section_currency': fields.boolean(string='Functional currency',
175 help='If this box is checked, this currency is used as a functional currency for at least one section in MSF.'),
176- 'is_esc_currency': fields.boolean(string='ESC currency',
177+ 'is_esc_currency': fields.boolean(string='ESC currency',
178 help='If this box is checked, this currency is used as a currency for at least one ESC.'),
179 'is_po_functional': fields.function(_get_in_search, fnct_search=_search_in_search, method=True,
180 type='boolean', string='transport PO currencies'),
181@@ -643,7 +643,7 @@
182 if property_ids:
183 properties = property_obj.browse(cr, uid, property_ids, context=context)
184 partner_list = ' / '.join(x.res_id.name for x in properties)
185- raise osv.except_osv(_('Error !'),
186+ raise osv.except_osv(_('Error !'),
187 _('You cannot uncheck the ESC checkbox because this currency is used on these \'ESC\' partners : \
188 %s' % partner_list))
189
190
191=== modified file 'bin/addons/sync_so/sale.py'
192--- bin/addons/sync_so/sale.py 2018-04-17 08:54:07 +0000
193+++ bin/addons/sync_so/sale.py 2018-09-14 08:02:39 +0000
194@@ -161,6 +161,12 @@
195
196 header_result = {}
197 so_po_common_obj.retrieve_so_header_data(cr, uid, source, header_result, po_dict, context)
198+
199+ if header_result.get('currency_id') and header_result.get('pricelist_id'):
200+ if not self.pool.get('product.pricelist').search_exist(cr, uid, [('id', '=', header_result['pricelist_id']), ('currency_id', '=', header_result['currency_id'])]):
201+ po_cur = self.pool.get('res.currency').read(cr, uid, header_result['currency_id'], ['name'], context=context)
202+ raise Exception, "Wrong FO/PO Currency on partner: please set FO/PO currency to %s on partner %s" % (po_cur['name'], source)
203+
204 header_result['order_line'] = so_po_common_obj.get_lines(cr, uid, source, po_info, False, False, False, True, context)
205 # [utp-360] we set the confirmed_delivery_date to False directly in creation and not in modification
206 order_line = []
207
208=== modified file 'bin/addons/sync_so/so_po_common.py'
209--- bin/addons/sync_so/so_po_common.py 2018-04-17 09:09:35 +0000
210+++ bin/addons/sync_so/so_po_common.py 2018-09-14 08:02:39 +0000
211@@ -342,6 +342,10 @@
212 if price_list:
213 price_list = self.pool.get('product.pricelist').find_sd_ref(cr, uid, xmlid_to_sdref(price_list['id']), context=context)
214
215+ currency_id = False
216+ if header_info.get('currency_id'):
217+ currency_id = self.pool.get('res.currency').find_sd_ref(cr, uid, xmlid_to_sdref(header_info['currency_id']['id']), context=context)
218+
219 # at the end, if there is no price list, just use the one from the partner
220 if not price_list:
221 price_list = self.get_price_list_id(cr, uid, partner_id, context)
222@@ -352,7 +356,7 @@
223 header_result['partner_shipping_id'] = address_id
224 header_result['partner_invoice_id'] = address_id
225 header_result['pricelist_id'] = price_list
226-
227+ header_result['currency_id'] = currency_id
228 return header_result
229
230 def get_product_id(self, cr, uid, data, default_code=False, context=None):

Subscribers

People subscribed via source and target branches