Merge lp:~unifield-team/unifield-server/us-471 into lp:unifield-server
- us-471
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 3639 |
Proposed branch: | lp:~unifield-team/unifield-server/us-471 |
Merge into: | lp:unifield-server |
Diff against target: |
227 lines (+116/-5) 4 files modified
bin/addons/msf_outgoing/msf_outgoing.py (+39/-1) bin/addons/msf_outgoing/msf_outgoing_view.xml (+7/-2) bin/addons/stock_override/stock.py (+44/-0) bin/addons/stock_override/stock_view.xml (+26/-2) |
To merge this branch: | bzr merge lp:~unifield-team/unifield-server/us-471 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+288905@code.launchpad.net |
Commit message
Description of the change
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_outgoing/msf_outgoing.py' |
2 | --- bin/addons/msf_outgoing/msf_outgoing.py 2016-03-02 15:57:47 +0000 |
3 | +++ bin/addons/msf_outgoing/msf_outgoing.py 2016-03-14 10:05:23 +0000 |
4 | @@ -26,6 +26,7 @@ |
5 | |
6 | from order_types.stock import check_cp_rw |
7 | from msf_order_date import TRANSPORT_TYPE |
8 | +from msf_partner import PARTNER_TYPE |
9 | |
10 | from dateutil.relativedelta import relativedelta |
11 | import decimal_precision as dp |
12 | @@ -245,6 +246,33 @@ |
13 | ''' % (args[0][1], args[0][2])) |
14 | return [('id', 'in', [x[0] for x in cr.fetchall()])] |
15 | |
16 | + def _get_is_company(self, cr, uid, ids, field_name, args, context=None): |
17 | + """ |
18 | + Return True if the partner_id2 of the shipment is the same partner |
19 | + as the partner linked to res.company of the res.users |
20 | + :param cr: Cursor to the database |
21 | + :param uid: ID of the res.users that calls this method |
22 | + :param ids: List of ID of shipment to update |
23 | + :param field_name: List of names of fields to update |
24 | + :param args: Extra parametrer |
25 | + :param context: Context of the call |
26 | + :return: A dictionary with shipment ID as keys and True or False a values |
27 | + """ |
28 | + user_obj = self.pool.get('res.users') |
29 | + |
30 | + if context is None: |
31 | + context = {} |
32 | + |
33 | + if isinstance(ids, (int, long)): |
34 | + ids = [ids] |
35 | + |
36 | + res = {} |
37 | + cmp_partner_id = user_obj.browse(cr, uid, uid, context=context).company_id.partner_id.id |
38 | + for ship in self.browse(cr, uid, ids, context=context): |
39 | + res[ship.id] = ship.partner_id2.id == cmp_partner_id |
40 | + |
41 | + return res |
42 | + |
43 | _columns = {'name': fields.char(string='Reference', size=1024), |
44 | 'date': fields.datetime(string='Creation Date'), |
45 | 'shipment_expected_date': fields.datetime(string='Expected Ship Date'), |
46 | @@ -290,6 +318,7 @@ |
47 | # functions |
48 | 'partner_id': fields.related('address_id', 'partner_id', type='many2one', relation='res.partner', string='Customer', store=True), |
49 | 'partner_id2': fields.many2one('res.partner', string='Customer', required=False), |
50 | + 'partner_type': fields.related('partner_id', 'partner_type', type='selection', selection=PARTNER_TYPE, readonly=True), |
51 | 'total_amount': fields.function(_vals_get, method=True, type='float', string='Total Amount', multi='get_vals',), |
52 | 'currency_id': fields.function(_vals_get, method=True, type='many2one', relation='res.currency', string='Currency', multi='get_vals',), |
53 | 'num_of_packs': fields.function(_vals_get, method=True, fnct_search=_packs_search, type='integer', string='Number of Packs', multi='get_vals_X',), # old_multi ship_vals |
54 | @@ -315,7 +344,16 @@ |
55 | string='Associated Packing List', |
56 | ), |
57 | 'in_ref': fields.char(string='IN Reference', size=1024), |
58 | - } |
59 | + 'is_company': fields.function( |
60 | + _get_is_company, |
61 | + method=True, |
62 | + type='boolean', |
63 | + string='Is Company ?', |
64 | + store={ |
65 | + 'shipment': (lambda self, cr, uid, ids, c={}: ids, ['partner_id2'], 10), |
66 | + } |
67 | + ), |
68 | + } |
69 | |
70 | def _get_sequence(self, cr, uid, context=None): |
71 | ir_id = self.pool.get('ir.model.data')._get_id(cr, uid, 'msf_outgoing', 'seq_shipment') |
72 | |
73 | === modified file 'bin/addons/msf_outgoing/msf_outgoing_view.xml' |
74 | --- bin/addons/msf_outgoing/msf_outgoing_view.xml 2016-01-14 15:38:57 +0000 |
75 | +++ bin/addons/msf_outgoing/msf_outgoing_view.xml 2016-03-14 10:05:23 +0000 |
76 | @@ -1222,7 +1222,8 @@ |
77 | <field name="address_id" context="{'contact_display':'partner'}" |
78 | domain="[('partner_id', '=', partner_id2)]" |
79 | attrs="{'readonly': ['|', ('partner_id2', '=', False), ('state', 'in', ('done', 'cancel', 'delivered'))]}" /> |
80 | - <field name="in_ref" readonly="True" /> |
81 | + <field name="in_ref" readonly="True" /> |
82 | + <field name="partner_type" invisible="True" readonly="True" /> |
83 | </group> |
84 | </group> |
85 | |
86 | @@ -1286,13 +1287,17 @@ |
87 | </field> |
88 | <group col="12" colspan="4"> |
89 | <field name="state" readonly="1"/> |
90 | + <field name="is_company" invisible="1" /> |
91 | <button name="return_packs" states="draft" string="Return Packs to Stock..." type="object" icon="gtk-undo" context="{'from_button': True}" /> |
92 | <button name="create_shipment" states="draft" string="Create Shipment..." type="object" icon="gtk-add" context="{'from_button': True}" /> |
93 | <button name="action_cancel" states="packed" string="Cancel Shipment" type="object" icon="gtk-cancel" /> |
94 | <button name="ship" states="packed" string="Ship" type="object" icon="gtk-redo" /> |
95 | <button name="return_packs_from_shipment" states="shipped" string="Return Packs from Shipment..." type="object" icon="gtk-undo" context="{'from_button': True}" /> |
96 | <button name="validate" states="shipped" string="Validate" type="object" icon="gtk-apply" context="{'from_button': True}" /> |
97 | - <button name="set_delivered" icon="gtk-apply" type="object" string="Validate Delivery" attrs="{'invisible': [('state', '!=', 'done')]}" |
98 | + <button name="set_delivered" icon="gtk-apply" type="object" string="Validate Delivery" |
99 | + attrs="{'invisible': ['|', '&', ('is_company', '=', False), ('partner_type', 'in', ['internal', 'intermission', 'section']), ('state', '!=', 'done')]}" /> |
100 | + <button name="set_delivered" icon="gtk-apply" type="object" string="Validate Delivery" |
101 | + attrs="{'invisible': ['|', '|', ('is_company', '=', True), ('partner_type', 'not in', ['internal', 'intermission', 'section']), ('state', '!=', 'done')]}" |
102 | confirm="Synchronization engine should confirm the delivery at the project reception, are you sure?"/> |
103 | </group> |
104 | </page> |
105 | |
106 | === modified file 'bin/addons/stock_override/stock.py' |
107 | --- bin/addons/stock_override/stock.py 2016-02-19 14:17:49 +0000 |
108 | +++ bin/addons/stock_override/stock.py 2016-03-14 10:05:23 +0000 |
109 | @@ -36,6 +36,8 @@ |
110 | from order_types.stock import check_cp_rw |
111 | from order_types.stock import check_rw_warning |
112 | |
113 | +from msf_partner import PARTNER_TYPE |
114 | + |
115 | |
116 | #---------------------------------------------------------- |
117 | # Procurement Order |
118 | @@ -269,6 +271,32 @@ |
119 | |
120 | return res |
121 | |
122 | + def _get_is_company(self, cr, uid, ids, field_name, args, context=None): |
123 | + """ |
124 | + Return True if the partner_id2 of the stock.picking is the same partner |
125 | + as the partner linked to res.company of the res.users |
126 | + :param cr: Cursor to the database |
127 | + :param uid: ID of the res.users that calls this method |
128 | + :param ids: List of ID of stock.picking to update |
129 | + :param field_name: List of names of fields to update |
130 | + :param args: Extra parametrer |
131 | + :param context: Context of the call |
132 | + :return: A dictionary with stock.picking ID as keys and True or False a values |
133 | + """ |
134 | + user_obj = self.pool.get('res.users') |
135 | + |
136 | + if context is None: |
137 | + context = {} |
138 | + |
139 | + if isinstance(ids, (int, long)): |
140 | + ids = [ids] |
141 | + |
142 | + res = {} |
143 | + cmp_partner_id = user_obj.browse(cr, uid, uid, context=context).company_id.partner_id.id |
144 | + for pick in self.browse(cr, uid, ids, context=context): |
145 | + res[pick.id] = pick.partner_id2.id == cmp_partner_id |
146 | + |
147 | + return res |
148 | |
149 | _columns = { |
150 | 'state': fields.selection([ |
151 | @@ -291,6 +319,13 @@ |
152 | 'from_yml_test': fields.boolean('Only used to pass addons unit test', readonly=True, help='Never set this field to true !'), |
153 | 'address_id': fields.many2one('res.partner.address', 'Delivery address', help="Address of partner", readonly=False, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, domain="[('partner_id', '=', partner_id)]"), |
154 | 'partner_id2': fields.many2one('res.partner', 'Partner', required=False), |
155 | + 'partner_type': fields.related( |
156 | + 'partner_id', |
157 | + 'partner_type', |
158 | + type='selection', |
159 | + selection=PARTNER_TYPE, |
160 | + readonly=True, |
161 | + ), |
162 | 'from_wkf': fields.boolean('From wkf'), |
163 | 'from_wkf_sourcing': fields.boolean('From wkf sourcing'), |
164 | 'update_version_from_in_stock_picking': fields.integer(string='Update version following IN processing'), |
165 | @@ -319,6 +354,15 @@ |
166 | store=False, |
167 | ), |
168 | 'company_id2': fields.many2one('res.partner', string='Company', required=True), |
169 | + 'is_company': fields.function( |
170 | + _get_is_company, |
171 | + method=True, |
172 | + type='boolean', |
173 | + string='Is Company ?', |
174 | + store={ |
175 | + 'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['partner_id2'], 10), |
176 | + } |
177 | + ) |
178 | } |
179 | |
180 | _defaults = {'from_yml_test': lambda *a: False, |
181 | |
182 | === modified file 'bin/addons/stock_override/stock_view.xml' |
183 | --- bin/addons/stock_override/stock_view.xml 2016-02-09 14:13:56 +0000 |
184 | +++ bin/addons/stock_override/stock_view.xml 2016-03-14 10:05:23 +0000 |
185 | @@ -831,8 +831,9 @@ |
186 | <form string="Delivery Orders"> |
187 | <group col="6" colspan="4"> |
188 | <group colspan="4" col="4"> |
189 | + <field name="partner_type" invisible="True" readonly="True" /> |
190 | <field name="name" readonly="1"/> |
191 | - <field name="origin" readonly="1"/> |
192 | + <field name="origin" readonly="1" /> |
193 | <field name="partner_id2" |
194 | on_change="on_change_partner(partner_id2, address_id)" |
195 | required="1" |
196 | @@ -995,7 +996,30 @@ |
197 | <field name="state" invisible="True"/> |
198 | <field name="delivered" invisible="True"/> |
199 | <field name="state_hidden"/> |
200 | - <button name="set_delivered" icon="gtk-apply" type="object" string="Confirm Delivery" attrs="{'invisible': ['|', '|', '|', ('type', '!=', 'out'), ('subtype', '!=', 'standard'), ('state', '!=', 'done'), ('delivered', '=', True)]}"/> |
201 | + <field name="is_company" invisible="1" /> |
202 | + <button name="set_delivered" |
203 | + icon="gtk-apply" |
204 | + type="object" |
205 | + string="Confirm Delivery" |
206 | + attrs="{'invisible': ['|', '|', '|', '|', '|', |
207 | + ('type', '!=', 'out'), ('subtype', '!=', 'standard'), |
208 | + ('state', '!=', 'done'), ('delivered', '=', True), |
209 | + ('partner_type', 'not in', ['internal', 'intermission', 'section']), |
210 | + ('is_company', '=', True), |
211 | + ]}" |
212 | + confirm="Synchronization engine should confirm the delivery at the project reception, are you sure?" |
213 | + /> |
214 | + <button name="set_delivered" |
215 | + icon="gtk-apply" |
216 | + type="object" |
217 | + string="Confirm Delivery" |
218 | + attrs="{'invisible': ['|', '|', '|', '|', |
219 | + ('type', '!=', 'out'), ('subtype', '!=', 'standard'), |
220 | + ('state', '!=', 'done'), ('delivered', '=', True), |
221 | + '&', |
222 | + ('partner_type', 'in', ['internal', 'intermission', 'section']), |
223 | + ('is_company', '=', False), |
224 | + ]}"/> |
225 | <field name="cross_docking_ok" invisible="1"/> |
226 | <!--<button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel"/>--> |
227 | <button name="call_cancel_wizard" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel" type="object" context="{'from_button': True}" /> |