Merge lp:~npg-team/openobject-addons/sale_negotiated_shipping_npg into lp:openobject-addons

Proposed by Novapoint Group
Status: Rejected
Rejected by: Fabien (Open ERP)
Proposed branch: lp:~npg-team/openobject-addons/sale_negotiated_shipping_npg
Merge into: lp:openobject-addons
Diff against target: 1508 lines (+1419/-0)
16 files modified
sale_negotiated_shipping/Change Log.txt (+18/-0)
sale_negotiated_shipping/__init__.py (+27/-0)
sale_negotiated_shipping/__openerp__.py (+44/-0)
sale_negotiated_shipping/invoice_view.xml (+73/-0)
sale_negotiated_shipping/invoice_weight.py (+201/-0)
sale_negotiated_shipping/sale_negotiate.py (+106/-0)
sale_negotiated_shipping/sale_negotiate_view.xml (+184/-0)
sale_negotiated_shipping/security/ir.model.access.csv (+17/-0)
sale_negotiated_shipping/security/sale_security.xml (+13/-0)
sale_negotiated_shipping/shipping_rate_table.py (+175/-0)
sale_negotiated_shipping/shipping_rate_table_view.xml (+167/-0)
sale_negotiated_shipping/wizard/__init__.py (+26/-0)
sale_negotiated_shipping/wizard/assigned_picker.py (+66/-0)
sale_negotiated_shipping/wizard/wizard_shipping_rate_calculation.py (+256/-0)
sale_negotiated_shipping/wizard/wizard_shipping_rate_view.xml (+36/-0)
sale_negotiated_shipping/wizard_view.xml (+10/-0)
To merge this branch: bzr merge lp:~npg-team/openobject-addons/sale_negotiated_shipping_npg
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Disapprove
Review via email: mp+78441@code.launchpad.net

Description of the change

NovaPoint Group has developed this module to add the capability for companies to setup a negotiated shipping option. This is where a company upcharges shipping, and bases shipping on a variety of shipping zones, shippers, and rates.

To post a comment you must log in.
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

Hello,

Thank you for this good contribution. I checked your branches and I would suggest to keep them in your own branch for now on, instead of putting them in the official release. Please register them in apps.openerp.com if it's not already done; if people use them in v6.1, we will think about merging them to the official branch.

As these modules have thousands lines of code, we would not have the time to efficiently review the code, check the usability experience and test for v6.1. I propose to review this later on, if we see people using it from apps.

Thanks,

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :
Download full text (4.4 KiB)

Hello,

I would like to explain a little bit more why this merge proposal was rejected, in 2 parts: first explaining our policy for merge proposals, then giving some hints about this specific merge proposal.

1. Merge Proposal Acceptance Policy
===================================
There may have been contradicting messages about how and when it is useful to make a merge proposal.
We would like to state this policy very clearly, especially now that extra-addons have been deprecated due to the introduction of OpenERP Apps. So we have now added an official Merge Proposal Acceptance Policy to our contributor documentation: http://bit.ly/openerp-contrib-mp

Here is the important part:
"""
OpenERP's R&D expects to receive merge proposals from the Community in these areas:
  - patches to correct a bug in an official addons
  - patches to improve an existing official addon, such as extending a feature or adding one

OpenERP's R&D does *not* expect to receive merge proposals from the Community in these areas:
  - addition of an extra feature to an official addons, when the feature
    should really provided by a separate (new) module
  - addition of a new module to the official addons

For these last cases, it is better to put the feature into new modules entirely maintained by their authors in their own Launchpad repository, and published on OpenERP Apps, to be visible by the whole Community. This is totally unrelated to the quality of the proposition: there are tons of great community modules on OpenERP Apps, some of them already downloaded thousands of times!

However, including a module in the official release is a big commitment in terms of review maintenance, support, etc. In addition, it would quickly bloat the OpenERP core if done too often, compromising its agility and maintainability, and thus the future of the product.
On the other hand, by progressively integrating OpenERP Apps better in the product, we should reach the same visibility for Community modules, without incurring these risks.

Therefore the process of including a community module into the official addons is entirely driven by OpenERP R&D based on the product strategy. In addition to features selected by OpenERP Product Managers, features that are considered REQUIRED to use OpenERP in a certain market/domain will also be considered for inclusion.
Deciding whether a feature is REQUIRED is quite subjective, but the following hints are useful:
 - if most established competitors on the given market/domain implement this feature, and
   this domain is normally addressed by official OpenERP addons, then it's likely REQUIRED.
 - on the other hand, if *no* established software competitors on the given market/domain
   implement this feature, then it's probably NOT REQUIRED
This certainly doesn't mean we don't want to innovate (that's the part where Product Managers choose new features!), this is only for deciding that a module is REQUIRED and thus it is *necessary* to include it in the default installations.

Of course, on top of the above, a merge proposal needs to pass the functional and technical review by OpenERP’s R&D, and even though we do our best to process them in a timely fas...

Read more...

review: Disapprove

Unmerged revisions

5306. By Novapoint Group

[Add]: sale_negotiated_shipping module to provide capability for companies to setup a negotiated shipping option

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'sale_negotiated_shipping'
2=== added file 'sale_negotiated_shipping/Change Log.txt'
3--- sale_negotiated_shipping/Change Log.txt 1970-01-01 00:00:00 +0000
4+++ sale_negotiated_shipping/Change Log.txt 2011-10-06 16:09:21 +0000
5@@ -0,0 +1,18 @@
6+===============================================================================
7+ Version Change Log (sale_negotiated_shipping)
8+===============================================================================
9+ 1.4 -> 1.5 (by Vinod on 19 Sept. 2011)
10+ * Calculation of tax for shipment in invoice and sale order.
11+
12+ 1.3 -> 1.4 (by Jabir on 28 June 2011)
13+ * Consider shipping charge on invoice refund
14+ 1.2 -> 1.3 (by Jabir on 6 June 2011)
15+ * Created account moves for shipping charge
16+ 1.1 -> 1.2
17+ * Wizard to calculate shipping rate
18+ * Added total weight, shipping charge, shipping method and ship calculation button on invoice view
19+ * Renaming Untaxed to Net Total on invoice view
20+ * Adds button in Sale order form to invoke wizard to calculate the shipping rate
21+ * Added shipping method on delivery order and delivery products
22+ * Adds fields Zone, State and Rate configuration to Ups Zone Map tree view form view and menu
23+ * Added menu view and menu for Shipping Rate Configuration,Shipping Rate Card and Ups Shipping Rate
24\ No newline at end of file
25
26=== added file 'sale_negotiated_shipping/__init__.py'
27--- sale_negotiated_shipping/__init__.py 1970-01-01 00:00:00 +0000
28+++ sale_negotiated_shipping/__init__.py 2011-10-06 16:09:21 +0000
29@@ -0,0 +1,27 @@
30+# -*- coding: utf-8 -*-
31+##############################################################################
32+#
33+# OpenERP, Open Source Management Solution
34+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
35+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
36+#
37+# This program is free software: you can redistribute it and/or modify
38+# it under the terms of the GNU General Public License as published by
39+# the Free Software Foundation, either version 3 of the License, or
40+# (at your option) any later version.
41+#
42+# This program is distributed in the hope that it will be useful,
43+# but WITHOUT ANY WARRANTY; without even the implied warranty of
44+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45+# GNU General Public License for more details.
46+#
47+# You should have received a copy of the GNU General Public License
48+# along with this program. If not, see <http://www.gnu.org/licenses/>
49+#
50+##############################################################################
51+
52+import sale_negotiate
53+import shipping_rate_table
54+import invoice_weight
55+import wizard
56+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
57\ No newline at end of file
58
59=== added file 'sale_negotiated_shipping/__openerp__.py'
60--- sale_negotiated_shipping/__openerp__.py 1970-01-01 00:00:00 +0000
61+++ sale_negotiated_shipping/__openerp__.py 2011-10-06 16:09:21 +0000
62@@ -0,0 +1,44 @@
63+# -*- coding: utf-8 -*-
64+##############################################################################
65+#
66+# OpenERP, Open Source Management Solution
67+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
68+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
69+#
70+# This program is free software: you can redistribute it and/or modify
71+# it under the terms of the GNU General Public License as published by
72+# the Free Software Foundation, either version 3 of the License, or
73+# (at your option) any later version.
74+#
75+# This program is distributed in the hope that it will be useful,
76+# but WITHOUT ANY WARRANTY; without even the implied warranty of
77+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78+# GNU General Public License for more details.
79+#
80+# You should have received a copy of the GNU General Public License
81+# along with this program. If not, see <http://www.gnu.org/licenses/>
82+#
83+##############################################################################
84+
85+{
86+ 'name': 'Zip',
87+ 'version': '1.5',
88+ 'category': 'Generic Modules/Others',
89+ 'description': """
90+ """,
91+ 'author': 'NovaPoint Group LLC',
92+ 'website': ' http://www.novapointgroup.com',
93+ 'depends': ['base','sale','sale_weight'],
94+ 'init_xml': [],
95+ 'update_xml': [
96+ 'shipping_rate_table_view.xml' ,
97+ 'wizard/wizard_shipping_rate_view.xml',
98+ 'sale_negotiate_view.xml',
99+ 'security/ir.model.access.csv',
100+ 'invoice_view.xml',],
101+ 'demo_xml': [
102+ ],
103+ 'installable': True,
104+ 'active': False,
105+}
106+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
107
108=== added file 'sale_negotiated_shipping/invoice_view.xml'
109--- sale_negotiated_shipping/invoice_view.xml 1970-01-01 00:00:00 +0000
110+++ sale_negotiated_shipping/invoice_view.xml 2011-10-06 16:09:21 +0000
111@@ -0,0 +1,73 @@
112+<?xml version="1.0"?>
113+<openerp>
114+ <data>
115+
116+ <!--Invoice Form -->
117+ <record id="invoice_form_inherit_1" model="ir.ui.view">
118+ <field name="name">account.invoice.form.inherit</field>
119+ <field name="model">account.invoice</field>
120+ <field name="inherit_id" ref="account.invoice_form"/>
121+ <field name="type">form</field>
122+ <field name="arch" type="xml">
123+ <xpath expr="//label[@string='']" position="replace">
124+ <field name="total_weight_net"/>
125+ <field name="shipcharge"/>
126+ <field name="ship_method"/>
127+ </xpath>
128+ <xpath expr="//button[@name='button_reset_taxes']" position="replace">
129+ <button colspan="1" name="button_reset_taxes" states="draft" string="Compute Taxes" type="object" groups="base.group_user" icon="terp-stock_format-scientific"/>
130+ <button colspan="1" name="%(action_view_for_shipping_rate_wizard)d" string="Calculate Shipping" type="action" help="Displays the shipping wizard." states="draft" groups="base.group_user" />
131+ </xpath>
132+
133+ </field>
134+ </record>
135+ <record id="invoice_supplier_form_inherit_1" model="ir.ui.view">
136+ <field name="name">account.invoice.supplier.form.inherit</field>
137+ <field name="model">account.invoice</field>
138+ <field name="inherit_id" ref="account.invoice_supplier_form"/>
139+ <field name="type">form</field>
140+ <field name="arch" type="xml">
141+ <xpath expr="//label[@string='']" position="replace">
142+ <field name="total_weight_net"/>
143+ <field name="shipcharge"/>
144+ <field name="ship_method"/>
145+ </xpath>
146+ <xpath expr="//button[@name='button_reset_taxes']" position="replace">
147+ <button colspan="1" name="button_reset_taxes" states="draft" string="Compute Taxes" type="object" groups="base.group_user" icon="terp-stock_format-scientific"/>
148+ <button colspan="1" name="%(action_view_for_shipping_rate_wizard)d" string="Calculate Shipping" type="action" help="Displays the shipping wizard." states="draft" groups="base.group_user" />
149+ </xpath>
150+
151+ </field>
152+ </record>
153+
154+
155+ <!-- Renaming Untaxed to Net Total on invoice view-->
156+
157+ <record id="account_invoice_view_changes_form_inherit01" model="ir.ui.view">
158+ <field name="name">account_invoice_view_changes_form_inherit01</field>
159+ <field name="model">account.invoice</field>
160+ <field name="type">form</field>
161+ <field name="inherit_id" ref="account.invoice_form"/>
162+ <field name="arch" type="xml">
163+ <xpath expr="//field[@name='amount_untaxed']" position="replace">
164+ <field name="amount_untaxed" string="Net Total"/>
165+ </xpath>
166+
167+ </field>
168+ </record>
169+ <record id="invoice_supplier_form_inherit01" model="ir.ui.view">
170+ <field name="name">invoice_supplier_form_inherit01</field>
171+ <field name="model">account.invoice</field>
172+ <field name="type">form</field>
173+ <field name="inherit_id" ref="account.invoice_supplier_form"/>
174+ <field name="arch" type="xml">
175+ <xpath expr="//field[@name='amount_untaxed']" position="replace">
176+ <field name="amount_untaxed" string="Net Total"/>
177+ </xpath>
178+
179+ </field>
180+ </record>
181+
182+
183+ </data>
184+</openerp>
185\ No newline at end of file
186
187=== added file 'sale_negotiated_shipping/invoice_weight.py'
188--- sale_negotiated_shipping/invoice_weight.py 1970-01-01 00:00:00 +0000
189+++ sale_negotiated_shipping/invoice_weight.py 2011-10-06 16:09:21 +0000
190@@ -0,0 +1,201 @@
191+# -*- coding: utf-8 -*-
192+##############################################################################
193+#
194+# OpenERP, Open Source Management Solution
195+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
196+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
197+#
198+# This program is free software: you can redistribute it and/or modify
199+# it under the terms of the GNU General Public License as published by
200+# the Free Software Foundation, either version 3 of the License, or
201+# (at your option) any later version.
202+#
203+# This program is distributed in the hope that it will be useful,
204+# but WITHOUT ANY WARRANTY; without even the implied warranty of
205+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
206+# GNU General Public License for more details.
207+#
208+# You should have received a copy of the GNU General Public License
209+# along with this program. If not, see <http://www.gnu.org/licenses/>
210+#
211+##############################################################################
212+
213+"""Compute the net weight of sale orders."""
214+
215+from osv import osv, fields
216+import decimal_precision as dp
217+import time
218+
219+class account_invoice(osv.osv):
220+ """Add the total net weight to the object "Sale Order"."""
221+
222+ _inherit = "account.invoice"
223+
224+ def _total_weight_net(self, cr, uid, ids, field_name, arg, context):
225+ """Compute the total net weight of the given Invoice."""
226+ result = {}
227+ for invoice in self.browse(cr, uid, ids, context=context):
228+ result[invoice.id] = 0.0
229+ for line in invoice.invoice_line:
230+ if line.product_id:
231+ result[invoice.id] += line.weight_net or 0.0
232+ return result
233+
234+ def _get_invoice(self, cr, uid, ids, context={}):
235+ """Get the invoice ids of the given Invoice Lines."""
236+ result = {}
237+ for line in self.pool.get('account.invoice.line').browse(cr, uid, ids,
238+ context=context):
239+ result[line.invoice_id.id] = True
240+ return result.keys()
241+
242+ def _amount_shipment_tax(self, cr, uid, shipment_taxes, shipment_charge):
243+ val = 0.0
244+ for c in self.pool.get('account.tax').compute_all(cr, uid, shipment_taxes, shipment_charge, 1)['taxes']:
245+ val += c.get('amount', 0.0)
246+ return val
247+
248+ def _amount_all(self, cr, uid, ids, name, args, context=None):
249+ res = super(account_invoice, self)._amount_all(cr, uid, ids, name, args, context=context)
250+ for invoice in self.browse(cr, uid, ids, context=context):
251+ if invoice.ship_method_id:
252+ res[invoice.id]['amount_total'] = res[invoice.id]['amount_untaxed'] + res[invoice.id]['amount_tax'] + invoice.shipcharge
253+ return res
254+
255+ def _get_invoice_tax(self, cr, uid, ids, context=None):
256+ invoice = self.pool.get('account.invoice')
257+ return super(account_invoice, invoice)._get_invoice_tax(cr, uid, ids, context=context)
258+
259+ def _get_invoice_line(self, cr, uid, ids, context=None):
260+ invoice = self.pool.get('account.invoice')
261+ return super(account_invoice, invoice)._get_invoice_line(cr, uid, ids, context=context)
262+
263+ def _get_invoice_from_line(self, cr, uid, ids, context=None):
264+ invoice = self.pool.get('account.invoice')
265+ return super(account_invoice, invoice)._get_invoice_from_line(cr, uid, ids, context=context)
266+
267+ def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines):
268+ """finalize_invoice_move_lines(cr, uid, invoice, move_lines) -> move_lines
269+ Hook method to be overridden in additional modules to verify and possibly alter the
270+ move lines to be created by an invoice, for special cases.
271+ :param invoice_browse: browsable record of the invoice that is generating the move lines
272+ :param move_lines: list of dictionaries with the account.move.lines (as for create())
273+ :return: the (possibly updated) final move_lines to create for this invoice
274+ """
275+ move_lines = super(account_invoice, self).finalize_invoice_move_lines(cr, uid, invoice_browse, move_lines)
276+ if invoice_browse.type == "out_refund":
277+ account = invoice_browse.account_id.id
278+ else:
279+ account = invoice_browse.sale_account_id.id
280+ if invoice_browse.sale_account_id and invoice_browse.shipcharge:
281+ lines1={
282+ 'analytic_account_id' : False,
283+ 'tax_code_id' : False,
284+ 'analytic_lines' : [],
285+ 'tax_amount' : False,
286+ 'name' : 'Shipping Charge',
287+ 'ref' : '',
288+ 'currency_id' : False,
289+ 'credit' : invoice_browse.shipcharge,
290+ 'product_id' : False,
291+ 'date_maturity' : False,
292+ 'debit' : False,
293+ 'date' : time.strftime("%Y-%m-%d"),
294+ 'amount_currency' : 0,
295+ 'product_uom_id' : False,
296+ 'quantity' : 1,
297+ 'partner_id' : invoice_browse.partner_id.id,
298+ 'account_id' : account,}
299+
300+ move_lines.append((0,0,lines1))
301+ # Retrieve the existing debit line if one exists
302+ has_entry = False
303+ for move_line in move_lines:
304+ journal_entry = move_line[2]
305+ if journal_entry['account_id'] == invoice_browse.journal_id.default_debit_account_id.id:
306+ journal_entry['debit'] += invoice_browse.shipcharge
307+ has_entry = True
308+ break
309+ # If debit line does not exist create one. Generally this condition will not happen. Just a fail-safe option
310+ if not has_entry:
311+ lines2={
312+ 'analytic_account_id' : False,
313+ 'tax_code_id' : False,
314+ 'analytic_lines' : [],
315+ 'tax_amount' : False,
316+ 'name' : '/',
317+ 'ref' : '',
318+ 'currency_id' : False,
319+ 'credit' : False,
320+ 'product_id' : False,
321+ 'date_maturity' : False,
322+ 'debit' : invoice_browse.shipcharge,
323+ 'date' : time.strftime("%Y-%m-%d"),
324+ 'amount_currency' : 0,
325+ 'product_uom_id' : False,
326+ 'quantity' : 1,
327+ 'partner_id' : invoice_browse.partner_id.id,
328+ 'account_id' : invoice_browse.journal_id.default_debit_account_id.id,}
329+
330+ move_lines.append((0,0,lines2))
331+ return move_lines
332+
333+
334+
335+
336+ _columns = {
337+
338+ 'amount_total': fields.function(_amount_all, method=True, digits_compute=dp.get_precision('Account'), string='Total',
339+ store={
340+ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line','shipcharge'], -10),
341+ 'account.invoice.tax': (_get_invoice_tax, None, -10),
342+ 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], -10),
343+ }, multi='all'),
344+
345+ 'total_weight_net': fields.function(_total_weight_net, method=True,
346+ readonly=True, string='Total Net Weight',
347+ help="The cumulated net weight of all the invoice lines.",
348+ store={
349+ # Low priority to compute this before fields in other modules
350+ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids,
351+ ['invoice_line'], 10),
352+ 'account.invoice.line': (_get_invoice,
353+ ['quantity', 'product_id'], 10),
354+ },
355+ ),
356+ 'shipcharge': fields.float('Shipping Cost', readonly=True),
357+ 'ship_method': fields.char('Shipping Method',size=128, readonly=True),
358+ 'ship_method_id': fields.many2one('shipping.rate.config','Shipping Method', readonly=True),
359+ 'sale_account_id':fields.many2one('account.account','Shipping Account',help='This account represents the g/l account for booking shipping income.', readonly=True)
360+
361+ }
362+account_invoice()
363+
364+# Record the net weight of the order line
365+class invoice_line(osv.osv):
366+ """Add the net weight to the object "Invoice Line"."""
367+ _inherit = 'account.invoice.line'
368+
369+ def _weight_net(self, cr, uid, ids, field_name, arg, context):
370+ """Compute the net weight of the given Invoice Lines."""
371+ result = {}
372+ for line in self.browse(cr, uid, ids, context=context):
373+ result[line.id] = 0.0
374+
375+ if line.product_id:
376+ result[line.id] += (line.product_id.weight_net
377+ * line.quantity)# / line.product_uom.factor)
378+ return result
379+ _columns = {
380+ 'weight_net': fields.function(_weight_net, method=True,
381+ readonly=True, string='Net Weight', help="The net weight in Kg.",
382+ store={
383+ # Low priority to compute this before fields in other modules
384+ 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids,
385+ ['quantity', 'product_id'], -11),
386+ },
387+ ),
388+
389+ }
390+invoice_line()
391+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
392
393=== added file 'sale_negotiated_shipping/sale_negotiate.py'
394--- sale_negotiated_shipping/sale_negotiate.py 1970-01-01 00:00:00 +0000
395+++ sale_negotiated_shipping/sale_negotiate.py 2011-10-06 16:09:21 +0000
396@@ -0,0 +1,106 @@
397+# -*- coding: utf-8 -*-
398+##############################################################################
399+#
400+# OpenERP, Open Source Management Solution
401+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
402+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
403+#
404+# This program is free software: you can redistribute it and/or modify
405+# it under the terms of the GNU General Public License as published by
406+# the Free Software Foundation, either version 3 of the License, or
407+# (at your option) any later version.
408+#
409+# This program is distributed in the hope that it will be useful,
410+# but WITHOUT ANY WARRANTY; without even the implied warranty of
411+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
412+# GNU General Public License for more details.
413+#
414+# You should have received a copy of the GNU General Public License
415+# along with this program. If not, see <http://www.gnu.org/licenses/>
416+#
417+##############################################################################
418+from osv import fields,osv
419+import decimal_precision as dp
420+import time
421+
422+#Shipping rate configuration model
423+class shipping_rate_config(osv.osv):
424+ _name = 'shipping.rate.config'
425+ _description = "Configuration for shipping rate"
426+ _rec_name = 'shipmethodname'
427+ _columns = {
428+ 'real_id':fields.integer('ID',readonly=True, ),
429+ 'shipmethodname':fields.char('Shipping Method Name',size=128,help='Shipping method name. Displayed in the wizard.'),
430+ 'active':fields.boolean('Active',help='Indicates whether a shipping method is active'),
431+ 'use':fields.boolean('Select',),
432+ 'calc_method':fields.selection([('country_weight','Country & Weight'),('state_zone_weight','State-Zone-Weight'),('manual','Manually Calculate')],'Shipping Calculation Method',help='Shipping method name. Displayed in the wizard.'),
433+ 'ups_shipping_wizard': fields.integer('Shipping Wizard'),
434+ 'rate_card_id':fields.many2one('ups.shipping.rate.card','Shipping Rate Card'),
435+ 'zone_map_ids':fields.one2many('ups.zone.map','rate_config_id','Zone Map'),
436+ 'account_id':fields.many2one('account.account','Account',help='This account represents the g/l account for booking shipping income.'),
437+ # Added to include tax configuration for shipment
438+ 'shipment_tax_ids': fields.many2many('account.tax', 'shipment_tax_rel', 'shipment_id', 'tax_id', 'Taxes', domain=[('parent_id','=',False)]),
439+ }
440+ _defaults = {
441+ 'calc_method':'country_weight'
442+ }
443+
444+shipping_rate_config()
445+
446+# State - Zone table
447+class zone_map(osv.osv):
448+ _name = 'ups.zone.map'
449+ _description = "Zone Mapping Table"
450+ _rec_name = 'zone'
451+ _columns = {
452+ 'zone':fields.integer('Zone'),
453+ 'state_id':fields.many2one('res.country.state','State / Zone'),
454+ 'rate_config_id':fields.many2one('shipping.rate.config','Shipping Rate Configuration')
455+ }
456+
457+zone_map()
458+'''
459+Adding shipping method field on delivery order and delivery products
460+'''
461+class stock_picking(osv.osv):
462+
463+ _inherit = "stock.picking"
464+ def _get_sale_order(self, cr, uid, ids, context={}):
465+ result = []
466+ for id in ids:
467+ stock_pick_ids = self.pool.get('stock.picking').search(cr,uid,[('sale_id','=',id)])
468+ result += stock_pick_ids
469+ result = list(set(result))
470+ return result
471+ _columns = {
472+ 'ship_method': fields.related('sale_id', 'ship_method', string='Shipping Method', type='char', size=128, #store=True
473+ store={
474+ 'sale.order': (_get_sale_order, ['ship_method'], -10),}
475+ ),
476+ }
477+
478+stock_picking()
479+class stock_move(osv.osv):
480+
481+ _inherit = "stock.move"
482+
483+ def _get_sale_order(self, cr, uid, ids, context={}):
484+ result = []
485+ move_ids = []
486+ for id in ids:
487+ stock_pick_ids = self.pool.get('stock.picking').search(cr,uid,[('sale_id','=',id)])
488+ if stock_pick_ids:
489+ move_ids += self.pool.get('stock.move').search(cr,uid,[('picking_id','in',stock_pick_ids)])
490+ move_ids = list(set(move_ids))
491+ return move_ids
492+ _columns = {
493+ 'ship_method': fields.related('picking_id','sale_id', 'ship_method', string='Shipping Method', type='char', size=128,# store=True
494+ store={
495+ 'sale.order': (_get_sale_order, ['ship_method'], -10),}
496+ ),
497+ }
498+
499+stock_move()
500+
501+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
502+
503
504=== added file 'sale_negotiated_shipping/sale_negotiate_view.xml'
505--- sale_negotiated_shipping/sale_negotiate_view.xml 1970-01-01 00:00:00 +0000
506+++ sale_negotiated_shipping/sale_negotiate_view.xml 2011-10-06 16:09:21 +0000
507@@ -0,0 +1,184 @@
508+<?xml version="1.0"?>
509+<openerp>
510+ <data>
511+ <!--Sale order form-->
512+
513+ <!--Adds button in Sale order form to invoke wizard to calculate the shipping rate-->
514+ <record model="ir.ui.view" id="sale_weight_form_inherit">
515+ <field name="name">sale_weight.view_form.inherit</field>
516+ <field name="model">sale.order</field>
517+ <field name="inherit_id" ref="sale_weight.sale_weight_form" />
518+ <field name="type">form</field>
519+ <field name="arch" type="xml">
520+ <field name="total_weight_net" position="replace"/>
521+ </field>
522+ </record>
523+
524+
525+ <record id="view_sale_order_inherit_1" model="ir.ui.view">
526+ <field name="name">view_sale_order_inherit_1</field>
527+ <field name="model">sale.order</field>
528+ <field name="inherit_id" ref="sale.view_order_form"/>
529+ <field name="type">form</field>
530+ <field name="arch" type="xml">
531+
532+ <xpath expr="//group[@colspan='10']" position="replace">
533+ <button name="button_dummy" states="draft" string="Compute" type="object" icon="gtk-execute" colspan="2"/>
534+ <button name="%(action_view_for_shipping_rate_wizard)d" string="Calculate Shipping" icon="terp-sale" type="action" help="Displays the shipping wizard." states="draft" colspan="2" />
535+ <group col="1" colspan="2">
536+ <field name="ship_method"/>
537+ <field name="total_weight_net" />
538+ </group>
539+ <group col="2" colspan="2">
540+ <field name="amount_untaxed" sum="Net Total" string="Net Total"/>
541+ <field name="shipcharge" help="The shipping charge on this order."/>
542+ <field name="amount_tax"/>
543+ <field name="amount_total"/>
544+ <label colspan="1"/><button name="%(sale.action_view_sale_advance_payment_inv)d" string="Advance Invoice"
545+ type="action" icon="gtk-execute" states="draft,manual" groups="base.group_extended"/>
546+ </group>
547+
548+
549+ </xpath>
550+ </field>
551+ </record>
552+ <!-- Delivery Orders -->
553+ <!-- Form -->
554+ <record id="view_picking_out_form_inherit" model="ir.ui.view">
555+ <field name="name">stock.picking.out.form.inherit</field>
556+ <field name="model">stock.picking</field>
557+ <field name="inherit_id" ref="stock.view_picking_out_form"/>
558+ <field name="type">form</field>
559+ <field name="arch" type="xml">
560+ <xpath expr="//field[@name='company_id']" position="after">
561+ <field name="ship_method"/>
562+ </xpath>
563+ </field>
564+ </record>
565+ <!-- Tree -->
566+ <record id="view_picking_out_tree_inherit" model="ir.ui.view">
567+ <field name="name">stock.picking.out.tree.inherit</field>
568+ <field name="model">stock.picking</field>
569+ <field name="inherit_id" ref="stock.view_picking_out_tree"/>
570+ <field name="type">tree</field>
571+ <field name="arch" type="xml">
572+ <xpath expr="//field[@name='backorder_id']" position="before">
573+ <field name="ship_method"/>
574+ </xpath>
575+ </field>
576+ </record>
577+ <!-- Search -->
578+ <record id="view_picking_internal_search_inherit" model="ir.ui.view">
579+ <field name="name">stock.picking.internal.search.inherit</field>
580+ <field name="model">stock.picking</field>
581+ <field name="type">search</field>
582+ <field name="inherit_id" ref="stock.view_picking_out_search"/>
583+ <field name="arch" type="xml">
584+ <xpath expr="//filter[@string='Journal']" position="after">
585+ <separator orientation="vertical" />
586+ <filter string="Shipping Method" icon="terp-product" domain="[]" context="{'group_by':'ship_method'}" groups="base.group_extended"/>
587+ </xpath>
588+ </field>
589+ </record>
590+
591+
592+ <!-- Deliver Products -->
593+ <!-- Tree -->
594+ <record id="view_move_tree_reception_picking_inherit" model="ir.ui.view">
595+ <field name="name">stock.move.tree2.inherit</field>
596+ <field name="model">stock.move</field>
597+ <field name="type">tree</field>
598+ <field name="inherit_id" ref="stock.view_move_tree_reception_picking"/>
599+ <field name="priority" eval="6" />
600+ <field name="arch" type="xml">
601+ <xpath expr="//field[@name='date']" position="after">
602+ <field name="ship_method"/>
603+ </xpath>
604+ </field>
605+ </record>
606+
607+ <!-- Form -->
608+ <record id="view_move_form_inherit" model="ir.ui.view">
609+ <field name="name">stock.move.form.inherit</field>
610+ <field name="model">stock.move</field>
611+ <field name="type">form</field>
612+ <field name="inherit_id" ref="stock.view_move_form"/>
613+ <field name="arch" type="xml">
614+ <xpath expr="//group[@col='4']" position="after">
615+ <group colspan="2" col="2" groups="base.group_extended">
616+ <separator string="Shipping" colspan="4" groups="base.group_extended"/>
617+ <field name="ship_method" readonly="1"/>
618+ </group>
619+ </xpath>
620+ </field>
621+ </record>
622+ <!-- Search -->
623+ <record id="view_move_search_reception_outcoming_picking_inherit" model="ir.ui.view">
624+ <field name="name">stock.move.outgoing.search2.inherit</field>
625+ <field name="model">stock.move</field>
626+ <field name="type">search</field>
627+ <field name="inherit_id" ref="stock.view_move_search_reception_outcoming_picking"/>
628+ <field eval="8" name="priority"/>
629+ <field name="arch" type="xml">
630+ <xpath expr="//filter[@string='Order Date']" position="after">
631+ <separator orientation="vertical" />
632+ <filter string="Shipping Method" icon="terp-product" domain="[]" context="{'group_by':'ship_method'}" groups="base.group_extended"/>
633+ </xpath>
634+ </field>
635+ </record>
636+
637+ <!--Zone Map Tree View-->
638+
639+ <!-- Adds fields Zone, State and Rate configuration to Ups Zone Map Tree View -->
640+
641+ <record id="zone_map_tree" model="ir.ui.view">
642+ <field name="name">ups.zone.map.tree</field>
643+ <field name="model">ups.zone.map</field>
644+ <field name="type">tree</field>
645+ <field name="arch" type="xml">
646+ <tree string='Zone Map'>
647+ <field name="zone" select="1"/>
648+ <field name="state_id" select="1"/>
649+ <field name="rate_config_id" select="1"/>
650+ </tree>
651+ </field>
652+ </record>
653+
654+ <!--Zone Map Form-->
655+
656+ <!--Adds fields Zone, State and Rate configuration to Ups Zone Map Form View-->
657+
658+ <record id="zone_map_form" model="ir.ui.view">
659+ <field name="name">ups.zone.map.form</field>
660+ <field name="model">ups.zone.map</field>
661+ <field name="type">form</field>
662+ <field name="arch" type="xml">
663+ <form string='Zone Map'>
664+ <field name="zone" select="1"/>
665+ <field name="state_id" select="1"/>
666+ <field name="rate_config_id" select="1"/>
667+ </form>
668+ </field>
669+ </record>
670+
671+ <!--Zone Map Action Record -->
672+
673+ <record id="zone_map_action" model="ir.actions.act_window">
674+ <field name="name">Zone Map</field>
675+ <field name="res_model">ups.zone.map</field>
676+ <field name="view_type">form</field>
677+ <field name="view_mode">tree,form</field>
678+ <field name="view_id" ref="zone_map_tree"/>
679+ </record>
680+
681+ <!-- Menu item for for Zone Map under the Menu Localisation-->
682+
683+ <menuitem
684+ id="zone_map_menu"
685+ name="Zone Map"
686+ parent="negotiated_shipping_config"
687+ action="zone_map_action" />
688+
689+
690+ </data>
691+</openerp>
692\ No newline at end of file
693
694=== added directory 'sale_negotiated_shipping/security'
695=== added file 'sale_negotiated_shipping/security/ir.model.access.csv'
696--- sale_negotiated_shipping/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
697+++ sale_negotiated_shipping/security/ir.model.access.csv 2011-10-06 16:09:21 +0000
698@@ -0,0 +1,17 @@
699+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
700+"security_ups_shipping_rate_card_salesman","security.ups.shipping.rate.card.salesman","model_ups_shipping_rate_card","base.group_sale_salesman",1,1,0,0
701+"security_ups_shipping_rate_card_erp_manager","security.ups.shipping.rate.card.erp.manager","model_ups_shipping_rate_card","base.group_erp_manager",1,1,1,1
702+"security_ups_shipping_rate_card_manager","security.ups.shipping.rate.card.manager","model_ups_shipping_rate_card","base.group_sale_manager",1,1,1,1
703+,,,,,,,
704+"security_ups_shipping_rate_salesman","security.ups.shipping.rate.salesman","model_ups_shipping_rate","base.group_sale_salesman",1,1,0,0
705+"security_ups_shipping_rate_erp_manager","security.ups.shipping.rate.erp.manager","model_ups_shipping_rate","base.group_erp_manager",1,1,1,1
706+"security_ups_shipping_rate_manager","security.ups.shipping.rate.manager","model_ups_shipping_rate","base.group_sale_manager",1,1,1,1
707+,,,,,,,
708+"security_ups_shipping_rate_config_salesman","security.ups.shipping.rate.config.salesman","model_shipping_rate_config","base.group_sale_salesman",1,1,0,0
709+"security_ups_shipping_rate_config_erp_manager","security.ups.shipping.rate.config.erp.manager","model_shipping_rate_config","base.group_erp_manager",1,1,1,1
710+"security_ups_shipping_rate_config_manager","security.ups.shipping.rate.config.manager","model_shipping_rate_config","base.group_sale_manager",1,1,1,1
711+,,,,,,,
712+"security_ups_zone_map_salesman","security.ups.zone.map.salesman","model_ups_zone_map","base.group_sale_salesman",1,1,0,0
713+"security_ups_zone_map_erp_manager","security.ups.zone.map.erp.manager","model_ups_zone_map","base.group_erp_manager",1,1,1,1
714+"security_ups_zone_map_manager","security.ups.zone.map.manager","model_ups_zone_map","base.group_sale_manager",1,1,1,1
715+
716
717=== added file 'sale_negotiated_shipping/security/sale_security.xml'
718--- sale_negotiated_shipping/security/sale_security.xml 1970-01-01 00:00:00 +0000
719+++ sale_negotiated_shipping/security/sale_security.xml 2011-10-06 16:09:21 +0000
720@@ -0,0 +1,13 @@
721+<?xml version="1.0" encoding="utf-8"?>
722+<openerp>
723+ <data noupdate="0">
724+
725+ <record id="group_shipping_manager" model="res.groups">
726+ <field name="name">Shipping / Manager</field>
727+ </record>
728+ <record id="group_shipping_user" model="res.groups">
729+ <field name="name">Shipping / User</field>
730+ </record>
731+
732+ </data>
733+</openerp>
734
735=== added file 'sale_negotiated_shipping/shipping_rate_table.py'
736--- sale_negotiated_shipping/shipping_rate_table.py 1970-01-01 00:00:00 +0000
737+++ sale_negotiated_shipping/shipping_rate_table.py 2011-10-06 16:09:21 +0000
738@@ -0,0 +1,175 @@
739+# -*- coding: utf-8 -*-
740+##############################################################################
741+#
742+# OpenERP, Open Source Management Solution
743+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
744+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
745+#
746+# This program is free software: you can redistribute it and/or modify
747+# it under the terms of the GNU General Public License as published by
748+# the Free Software Foundation, either version 3 of the License, or
749+# (at your option) any later version.
750+#
751+# This program is distributed in the hope that it will be useful,
752+# but WITHOUT ANY WARRANTY; without even the implied warranty of
753+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
754+# GNU General Public License for more details.
755+#
756+# You should have received a copy of the GNU General Public License
757+# along with this program. If not, see <http://www.gnu.org/licenses/>
758+#
759+##############################################################################
760+from osv import fields,osv
761+import decimal_precision as dp
762+import time
763+
764+
765+class shipping_rate_card(osv.osv):
766+ _name = 'ups.shipping.rate.card'
767+ _description = "Ground Shipping Calculation Table"
768+ _columns = {
769+ 'name':fields.char('Shipping Method',size=128,required=True),
770+ 'from_date':fields.datetime('From Date', ),
771+ 'to_date':fields.datetime('To Date', ),
772+ 'rate_ids': fields.one2many('ups.shipping.rate','card_id','Shipping Rates', required=True),
773+ }
774+
775+shipping_rate_card()
776+
777+class shipping_rate(osv.osv):
778+ _name = 'ups.shipping.rate'
779+ _description = "Shipping Calculation Table"
780+ _columns = {
781+ 'name':fields.char('Shipping Method',size=128),
782+ 'from_weight': fields.integer('From Weight', required=True),
783+ 'to_weight': fields.integer('To Weight'),
784+ 'charge': fields.float('Shipping Charge'),
785+ 'over_cost': fields.float('Shipping Charge per pound over'),
786+ 'country_id':fields.many2one('res.country','Country'),
787+ 'zone':fields.integer('Zone', required=True),
788+ 'card_id':fields.many2one('ups.shipping.rate.card','Shipping Table')
789+ }
790+
791+shipping_rate()
792+
793+class sale_order(osv.osv):
794+ _name = "sale.order"
795+ _inherit="sale.order"
796+ _description = "Sale Order"
797+
798+ def _make_invoice(self, cr, uid, order, lines, context=None):
799+ inv_id = super(sale_order, self)._make_invoice(cr, uid, order, lines, context=None)
800+ if inv_id and order._table_name == 'sale.order':
801+ if order.sale_account_id:
802+ self.pool.get('account.invoice').write(cr,uid,inv_id,{
803+ 'shipcharge':order.shipcharge,
804+ 'ship_method':order.ship_method,
805+ 'ship_method_id':order.ship_method_id.id,
806+ 'sale_account_id':order.sale_account_id.id,
807+ })
808+ self.pool.get('account.invoice').button_reset_taxes(cr, uid, [inv_id], context=context)
809+
810+ return inv_id
811+
812+ def _get_order(self, cr, uid, ids, context=None):
813+ return super(sale_order, self)._get_order(cr, uid, ids, context=context)
814+
815+ def _amount_shipment_tax(self, cr, uid, shipment_taxes, shipment_charge):
816+ val = 0.0
817+ for c in self.pool.get('account.tax').compute_all(cr, uid, shipment_taxes, shipment_charge, 1)['taxes']:
818+ val += c.get('amount', 0.0)
819+ return val
820+
821+ def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
822+ cur_obj = self.pool.get('res.currency')
823+ res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context=context)
824+ for order in self.browse(cr, uid, ids, context=context):
825+ cur = order.pricelist_id.currency_id
826+ if order.ship_method_id:
827+ if order.ship_method_id.shipment_tax_ids and len(order.ship_method_id.shipment_tax_ids) > 0:
828+ val = self._amount_shipment_tax(cr, uid, order.ship_method_id.shipment_tax_ids, order.shipcharge)
829+ res[order.id]['amount_tax'] += cur_obj.round(cr, uid, cur, val)
830+ res[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] + order.shipcharge
831+ return res
832+
833+ _columns = {
834+ 'shipcharge': fields.float('Shipping Cost', readonly=True),
835+ 'ship_method': fields.char('Shipping Method',size=128, readonly=True),
836+ 'ship_method_id': fields.many2one('shipping.rate.config','Shipping Method', readonly=True),
837+ 'sale_account_id':fields.many2one('account.account','Shipping Account',help='This account represents the g/l account for booking shipping income.', readonly=True),
838+ 'amount_untaxed': fields.function(_amount_all, method=True, digits_compute= dp.get_precision('Sale Price'), string='Untaxed Amount',
839+ store = {
840+ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'ship_method_id'], 10),
841+ 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
842+ },
843+ multi='sums', help="The amount without tax."),
844+ 'amount_tax': fields.function(_amount_all, method=True, digits_compute= dp.get_precision('Sale Price'), string='Taxes',
845+ store = {
846+ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'ship_method_id'], 10),
847+ 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
848+ },
849+ multi='sums', help="The tax amount."),
850+ 'amount_total': fields.function(_amount_all, method=True, digits_compute= dp.get_precision('Sale Price'), string='Total',
851+ store = {
852+ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'ship_method_id'], 10),
853+ 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
854+ },
855+ multi='sums', help="The total amount."),
856+ }
857+
858+sale_order()
859+
860+# Added to calculate tax for shipment in invoice
861+class account_invoice_tax_inherit(osv.osv):
862+ _name = "account.invoice.tax"
863+ _inherit = "account.invoice.tax"
864+
865+ def compute(self, cr, uid, invoice_id, context=None):
866+ tax_grouped = super(account_invoice_tax_inherit, self).compute(cr, uid, invoice_id, context=context)
867+ tax_obj = self.pool.get('account.tax')
868+ cur_obj = self.pool.get('res.currency')
869+ inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context)
870+ cur = inv.currency_id
871+ company_currency = inv.company_id.currency_id.id
872+
873+ if inv.ship_method_id and inv.ship_method_id.shipment_tax_ids and len(inv.ship_method_id.shipment_tax_ids) > 0:
874+ for tax in tax_obj.compute_all(cr, uid, inv.ship_method_id.shipment_tax_ids, inv.shipcharge, 1)['taxes']:
875+ val={}
876+ val['invoice_id'] = inv.id
877+ val['name'] = tax['name']
878+ val['amount'] = tax['amount']
879+ val['manual'] = False
880+ val['sequence'] = tax['sequence']
881+ val['base'] = tax['price_unit'] * 1
882+
883+ if inv.type in ('out_invoice','in_invoice'):
884+ val['base_code_id'] = tax['base_code_id']
885+ val['tax_code_id'] = tax['tax_code_id']
886+ val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
887+ val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
888+ val['account_id'] = tax['account_collected_id'] or line.account_id.id
889+ else:
890+ val['base_code_id'] = tax['ref_base_code_id']
891+ val['tax_code_id'] = tax['ref_tax_code_id']
892+ val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['ref_base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
893+ val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
894+ val['account_id'] = tax['account_paid_id'] or line.account_id.id
895+
896+ key = (val['tax_code_id'], val['base_code_id'], val['account_id'])
897+ if not key in tax_grouped:
898+ tax_grouped[key] = val
899+ else:
900+ tax_grouped[key]['amount'] += val['amount']
901+ tax_grouped[key]['base'] += val['base']
902+ tax_grouped[key]['base_amount'] += val['base_amount']
903+ tax_grouped[key]['tax_amount'] += val['tax_amount']
904+
905+ for t in tax_grouped.values():
906+ t['base'] = cur_obj.round(cr, uid, cur, t['base'])
907+ t['amount'] = cur_obj.round(cr, uid, cur, t['amount'])
908+ t['base_amount'] = cur_obj.round(cr, uid, cur, t['base_amount'])
909+ t['tax_amount'] = cur_obj.round(cr, uid, cur, t['tax_amount'])
910+ return tax_grouped
911+
912+account_invoice_tax_inherit()
913+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
914
915=== added file 'sale_negotiated_shipping/shipping_rate_table_view.xml'
916--- sale_negotiated_shipping/shipping_rate_table_view.xml 1970-01-01 00:00:00 +0000
917+++ sale_negotiated_shipping/shipping_rate_table_view.xml 2011-10-06 16:09:21 +0000
918@@ -0,0 +1,167 @@
919+<?xml version="1.0"?>
920+<openerp>
921+ <data>
922+ <!--Adds Menu for the Shipping Configuration-->
923+ <menuitem id="negotiated_shipping_config" parent="base.menu_base_config" name="Negotiated Shipping" sequence="55" groups="base.group_erp_manager,base.group_sale_manager,base.group_system"/>
924+
925+ <!--SHIPPING RATE-->
926+ <!--Tree view for Ups Shipping Rate-->
927+
928+ <record id="tree_view_for_shipping_rate" model="ir.ui.view">
929+ <field name="name">tree.view.for.shipping.rate</field>
930+ <field name="model">ups.shipping.rate</field>
931+ <field name="type">tree</field>
932+ <field name="arch" type="xml">
933+ <tree string='Shipping Rate'>
934+ <field name="name"/>
935+ <field name="from_weight"/>
936+ <field name="to_weight"/>
937+ <field name="charge"/>
938+ <field name="over_cost"/>
939+ <field name="country_id"/>
940+ <field name="zone"/>
941+ </tree>
942+ </field>
943+ </record>
944+
945+ <!--Form view for Ups Shipping Rate-->
946+
947+ <record id="form_view_for_shipping_rate" model="ir.ui.view">
948+ <field name="name">form.view.for.shipping.rate</field>
949+ <field name="model">ups.shipping.rate</field>
950+ <field name="type">form</field>
951+ <field name="arch" type="xml">
952+ <form string='Shipping Rate'>
953+ <group colspan="4" col="4" string="">
954+ <field name="name" select="1" colspan="1"/><newline/>
955+ <field name="from_weight" select="1" colspan="1"/>
956+ <field name="to_weight" select="1" colspan="1"/><newline/>
957+ <field name="charge" select="1" colspan="1"/>
958+ <field name="over_cost" select="1" colspan="1"/><label colspan="3"/><newline/>
959+ <field name="country_id" select="1" colspan="1"/>
960+ <field name="zone" attrs="{'invisible':[('name', '=', 'ups_ground')]}" />
961+ <field name="card_id"/>
962+ </group>
963+ </form>
964+ </field>
965+ </record>
966+
967+
968+ <!--Action Record for Shipping Rate-->
969+
970+ <record id="action_for_shipping_rate" model="ir.actions.act_window">
971+ <field name="name">Shipping Rates</field>
972+ <field name="res_model">ups.shipping.rate</field>
973+ <field name="view_type">form</field>
974+ <field name="view_mode">tree,form</field>
975+ <field name="view_id" ref="tree_view_for_shipping_rate"/>
976+ </record>
977+
978+ <!-- Shipping Rate menu-->
979+ <menuitem id="shipping_rate" parent="negotiated_shipping_config" sequence="55" action="action_for_shipping_rate" groups="base.group_erp_manager,base.group_sale_manager,base.group_system"/>
980+
981+ <!--SHIPPING RATE CARD-->
982+ <!-- Shipping Rate Card List View-->
983+
984+ <record id="tree_view_shipping_rate_table" model="ir.ui.view">
985+ <field name="name">tree.ups.shipping.rate.card</field>
986+ <field name="model">ups.shipping.rate.card</field>
987+ <field name="type">tree</field>
988+ <field name="arch" type="xml">
989+ <tree>
990+ <field name="name" select="1"/>
991+ <field name="from_date" select="1" colspan="1"/>
992+ <field name="to_date" select="1" colspan="1"/>
993+ </tree>
994+ </field>
995+ </record>
996+
997+ <!-- Shipping Rate Card Form View-->
998+
999+ <record id="form_view_shipping_rate_table" model="ir.ui.view">
1000+ <field name="name">form.ups.shipping.rate.card</field>
1001+ <field name="model">ups.shipping.rate.card</field>
1002+ <field name="type">form</field>
1003+ <field name="arch" type="xml">
1004+ <form>
1005+ <field name="name" select="1" colspan="2"/><newline/>
1006+ <field name="from_date" select="1" colspan="1"/>
1007+ <field name="to_date" select="1" colspan="1"/><newline/>
1008+ <separator string="Shipping Rates" colspan="4"/>
1009+ <field name="rate_ids" select="1" colspan="4" nolabel="1"/>
1010+ </form>
1011+ </field>
1012+ </record>
1013+
1014+
1015+ <!--Action Record for Shipping Rate Card-->
1016+
1017+ <record id="action_shipping_rate_table" model="ir.actions.act_window">
1018+ <field name="name">Shipping Methods</field>
1019+ <field name="res_model">ups.shipping.rate.card</field>
1020+ <field name="view_type">form</field>
1021+ <field name="view_mode">tree,form</field>
1022+ <field name="view_id" ref="tree_view_shipping_rate_table"/>
1023+ </record>
1024+ <menuitem id="shipping_rate_table" name="Shipping Methods" parent="negotiated_shipping_config" sequence="65" action="action_shipping_rate_table" groups="base.group_erp_manager,base.group_sale_manager,base.group_system" />
1025+
1026+ <!--SHIPPING RATE CONFIGURATION-->
1027+ <!-- Shipping Rate Configuration List View-->
1028+ <record id="tree_view_shipping_rate_config" model="ir.ui.view">
1029+ <field name="name">tree.shipping.rate.config</field>
1030+ <field name="model">shipping.rate.config</field>
1031+ <field name="type">tree</field>
1032+ <field name="arch" type="xml">
1033+ <tree editable="top">
1034+ <field name="shipmethodname"/>
1035+ <field name="active" select="1"/>
1036+ <field name="calc_method"/>
1037+ <field name="rate_card_id"/>
1038+ <field name="account_id" required="1"/>
1039+
1040+ </tree>
1041+ </field>
1042+ </record>
1043+
1044+ <!-- Shipping Rate Configuration Form View-->
1045+
1046+ <record id="form_view_shipping_rate_config" model="ir.ui.view">
1047+ <field name="name">form.shipping.rate.config</field>
1048+ <field name="model">shipping.rate.config</field>
1049+ <field name="type">form</field>
1050+ <field name="arch" type="xml">
1051+ <form>
1052+ <field name="shipmethodname" select="1" colspan="2"/>
1053+ <field name="active" select="1" colspan="2"/>
1054+ <field name="calc_method" select="1" colspan="2"/>
1055+ <field name="rate_card_id" select="1" colspan="2"/>
1056+ <field name="account_id" select="1" colspan="2" required="1"/>
1057+ <field name="shipment_tax_ids" colspan="2"/>
1058+ <newline/>
1059+ <group height="425" colspan="6" col="6">
1060+ <field name="zone_map_ids" attrs="{'invisible':[('calc_method','!=','state_zone_weight')]}" nolabel="1">
1061+ <tree string="Zone Map">
1062+ <field name="zone"/>
1063+ <field name="state_id"/>
1064+ </tree>
1065+ </field>
1066+ </group>
1067+ </form>
1068+ </field>
1069+ </record>
1070+
1071+
1072+ <!--Action Record for Shipping Rate Configuration and Menu-->
1073+
1074+ <record id="action_shipping_rate_config" model="ir.actions.act_window">
1075+ <field name="name">Shipping Rate Configuration</field>
1076+ <field name="res_model">shipping.rate.config</field>
1077+ <field name="view_type">form</field>
1078+ <field name="view_mode">tree,form</field>
1079+ <field name="view_id" ref="tree_view_shipping_rate_config"/>
1080+ </record>
1081+
1082+ <menuitem id="shipping_rate_config" name="Shipping Rate Configuration" parent="negotiated_shipping_config" sequence="75" action="action_shipping_rate_config" groups="base.group_erp_manager,base.group_sale_manager,base.group_system"/>
1083+
1084+ </data>
1085+</openerp>
1086\ No newline at end of file
1087
1088=== added directory 'sale_negotiated_shipping/wizard'
1089=== added file 'sale_negotiated_shipping/wizard/__init__.py'
1090--- sale_negotiated_shipping/wizard/__init__.py 1970-01-01 00:00:00 +0000
1091+++ sale_negotiated_shipping/wizard/__init__.py 2011-10-06 16:09:21 +0000
1092@@ -0,0 +1,26 @@
1093+# -*- coding: utf-8 -*-
1094+##############################################################################
1095+#
1096+# OpenERP, Open Source Management Solution
1097+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
1098+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
1099+#
1100+# This program is free software: you can redistribute it and/or modify
1101+# it under the terms of the GNU General Public License as published by
1102+# the Free Software Foundation, either version 3 of the License, or
1103+# (at your option) any later version.
1104+#
1105+# This program is distributed in the hope that it will be useful,
1106+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1107+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1108+# GNU General Public License for more details.
1109+#
1110+# You should have received a copy of the GNU General Public License
1111+# along with this program. If not, see <http://www.gnu.org/licenses/>
1112+#
1113+##############################################################################
1114+
1115+
1116+
1117+import wizard_shipping_rate_calculation
1118+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1119\ No newline at end of file
1120
1121=== added file 'sale_negotiated_shipping/wizard/assigned_picker.py'
1122--- sale_negotiated_shipping/wizard/assigned_picker.py 1970-01-01 00:00:00 +0000
1123+++ sale_negotiated_shipping/wizard/assigned_picker.py 2011-10-06 16:09:21 +0000
1124@@ -0,0 +1,66 @@
1125+# -*- encoding: utf-8 -*-
1126+##############################################################################
1127+#
1128+# OpenERP, Open Source Management Solution
1129+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
1130+# $Id$
1131+#
1132+# This program is free software: you can redistribute it and/or modify
1133+# it under the terms of the GNU General Public License as published by
1134+# the Free Software Foundation, either version 3 of the License, or
1135+# (at your option) any later version.
1136+#
1137+# This program is distributed in the hope that it will be useful,
1138+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1139+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1140+# GNU General Public License for more details.
1141+#
1142+# You should have received a copy of the GNU General Public License
1143+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1144+#
1145+##############################################################################
1146+
1147+import pooler
1148+import wizard
1149+from tools.translate import _
1150+
1151+pick_form = """<?xml version="1.0"?>
1152+<form string="Change Assigned Picker">
1153+ <field name="picker" colspan="4"/>
1154+</form>
1155+"""
1156+
1157+pick_fields = {
1158+ 'picker': {'string': 'Assigned Picker', 'type': 'many2one', 'relation': 'res.users'}
1159+}
1160+
1161+
1162+
1163+class wizard_assigned_picker(wizard.interface):
1164+
1165+
1166+ def do_action(self, cr, uid, data, context={}):
1167+ print data
1168+ pooler.get_pool(cr.dbname).get(data['model']).write(cr,uid,data['ids'],{'assigned_picker':data['form']['picker']})
1169+ return {}
1170+
1171+
1172+ states = {
1173+ 'init': {
1174+ 'actions': [],
1175+ 'result': {'type': 'form', 'arch': pick_form, 'fields' : pick_fields, 'state' : [('end', 'Cancel'), ('update_delivery', 'Update Delivery Order') ]}
1176+ },
1177+ 'update_delivery': {
1178+ 'actions': [],
1179+ 'result': {'type': 'action', 'action': do_action, 'state': 'end'}
1180+ },
1181+
1182+
1183+# 'init': {
1184+# 'actions': [],
1185+# 'result': {'type': 'action', 'action': do_action, 'state':'end'}
1186+# }
1187+ }
1188+wizard_assigned_picker('assigned_picker_order')
1189+
1190+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1191
1192=== added file 'sale_negotiated_shipping/wizard/wizard_shipping_rate_calculation.py'
1193--- sale_negotiated_shipping/wizard/wizard_shipping_rate_calculation.py 1970-01-01 00:00:00 +0000
1194+++ sale_negotiated_shipping/wizard/wizard_shipping_rate_calculation.py 2011-10-06 16:09:21 +0000
1195@@ -0,0 +1,256 @@
1196+# -*- coding: utf-8 -*-
1197+##############################################################################
1198+#
1199+# OpenERP, Open Source Management Solution
1200+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
1201+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
1202+#
1203+# This program is free software: you can redistribute it and/or modify
1204+# it under the terms of the GNU General Public License as published by
1205+# the Free Software Foundation, either version 3 of the License, or
1206+# (at your option) any later version.
1207+#
1208+# This program is distributed in the hope that it will be useful,
1209+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1210+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1211+# GNU General Public License for more details.
1212+#
1213+# You should have received a copy of the GNU General Public License
1214+# along with this program. If not, see <http://www.gnu.org/licenses/>
1215+#
1216+##############################################################################
1217+from osv import fields,osv
1218+import netsvc
1219+from tools.translate import _
1220+
1221+class shipping_rate_wizard(osv.osv_memory):
1222+ _name = "shipping.rate.wizard"
1223+ _description = "Calculates shipping charges"
1224+ _columns = {
1225+ 'name': fields.one2many('shipping.rate.config','ups_shipping_wizard','Shipping Method'),
1226+ 'shipping_cost':fields.float('Shipping Cost'),
1227+ 'last_used':fields.char('Last Used',size="128"),
1228+ 'account_id':fields.many2one('account.account', 'Account'),
1229+ 'rate_select': fields.many2one('shipping.rate.config','Select'),
1230+ }
1231+ def _get_default_val(self,cr, uid, ids,context={}):
1232+ '''
1233+ Function to initialize shipping methods in shipping charge calculating wizard
1234+ '''
1235+ ret=[]
1236+ ship_conf_obj = self.pool.get('shipping.rate.config')
1237+ ship_conf_ids = ship_conf_obj.search(cr,uid,[])
1238+ account_id = False
1239+ for ship_conf in ship_conf_obj.browse(cr,uid,ship_conf_ids):
1240+ if ship_conf.account_id:
1241+ account_id = ship_conf.account_id.id
1242+ ret.append({'shipmethodname':ship_conf.shipmethodname,'use': 0,'real_id':ship_conf.id,'account_id':account_id})
1243+ return ret
1244+ _defaults = {'name':_get_default_val,
1245+ 'last_used':'',
1246+
1247+ }
1248+ def update_sale_order(self, cr, uid, ids,context={}):
1249+ '''
1250+ Function to update sale order and invoice with new shipping cost and method
1251+ '''
1252+ datas = self.browse(cr, uid, ids[0], context=context)
1253+ if context.get('active_model',False) == 'sale.order':
1254+ sale_id = context.get('active_id',False)
1255+ sale_id and self.pool.get('sale.order').write(cr,uid,[sale_id],{'shipcharge':datas.shipping_cost,
1256+ 'ship_method':datas.last_used,
1257+ 'sale_account_id':datas.account_id.id,
1258+ 'ship_method_id':datas.rate_select.id,})
1259+ self.pool.get('sale.order').button_dummy(cr, uid, [sale_id], context=context)
1260+ elif context.get('active_model',False) == 'account.invoice':
1261+ invoice_id = context.get('active_id',False)
1262+ if invoice_id:
1263+ if datas.account_id:
1264+ account_id = datas.account_id.id
1265+ else:
1266+ account_id = False
1267+ self.pool.get('account.invoice').write(cr,uid,[invoice_id],{
1268+ 'shipcharge':datas.shipping_cost,
1269+ 'ship_method':datas.last_used,
1270+ 'ship_method_id':datas.rate_select.id,
1271+ 'sale_account_id':datas.account_id.id,
1272+ })
1273+ self.pool.get('account.invoice').button_reset_taxes(cr, uid, [invoice_id], context=context)
1274+# For future development to add invoice line for shipping method
1275+# inv_line_ids = self.pool.get('account.invoice.line').search(cr,uid,[('invoice_id','=',invoice_id),('name','=','Shipping Charge')])
1276+# if inv_line_ids:
1277+# self.pool.get('account.invoice').write(cr,uid,invoice_id,{
1278+# 'shipcharge':datas.shipping_cost,
1279+# 'ship_method':datas.last_used,
1280+# })
1281+# self.pool.get('account.invoice.line').write(cr,uid,inv_line_ids,{'price_unit':datas.shipping_cost})
1282+# else:
1283+# if datas.account_id:
1284+# self.pool.get('account.invoice').write(cr,uid,invoice_id,{
1285+# 'shipcharge':datas.shipping_cost,
1286+# 'ship_method':datas.last_used,
1287+# 'invoice_line':[(0,0,{'name':'Shipping Charge',
1288+# 'quantity':1,
1289+# 'state':'article',
1290+# 'account_id':datas.account_id.id,
1291+# 'price_unit':datas.shipping_cost})]
1292+# })
1293+# else:
1294+# raise osv.except_osv(_('Warning !'), _('No account defined for this shipping rate configuration.'))
1295+
1296+
1297+
1298+ return {}
1299+ def find_cost(self, cr, uid, config_id, address, model_obj, type='sale_order', context={}):
1300+ '''
1301+ Function to calculate shipping cost
1302+ '''
1303+ cost=0
1304+ table_pool = self.pool.get('ups.shipping.rate')
1305+ config_pool = self.pool.get('shipping.rate.config')
1306+ logger = netsvc.Logger()
1307+ config_obj = config_pool.browse(cr,uid,config_id, context=context)
1308+ if config_obj.calc_method == 'country_weight':
1309+ table_id = table_pool.search(cr,uid,[('card_id','=',config_obj.rate_card_id.id),('country_id','=',address.country_id.id),('from_weight','<=',model_obj.total_weight_net),('to_weight','>',model_obj.total_weight_net),])
1310+ if table_id:
1311+ table_obj = table_pool.browse(cr,uid,table_id[0],)
1312+ if table_obj.charge == 0.0 and table_obj.over_cost:
1313+ cost = model_obj.total_weight_net*table_obj.over_cost
1314+ else:
1315+ cost = table_obj.charge
1316+
1317+ else:
1318+ table_ids = table_pool.search(cr,uid,[('card_id','=',config_obj.rate_card_id.id),('country_id','=',address.country_id.id),('over_cost','>',0)])
1319+ if table_ids:
1320+ table_objs = table_pool.browse(cr,uid,table_ids)
1321+ table_obj = table_objs[0]
1322+ for table in table_objs:
1323+ if table_obj.from_weight < table.from_weight:
1324+ table_obj = table
1325+ weight = model_obj.total_weight_net
1326+ if table_obj.charge > 0:
1327+ cost = table_obj.charge
1328+ weight -= table_obj.from_weight
1329+ if weight>0:
1330+ cost += weight*table_obj.over_cost
1331+ else:
1332+ cost = weight*table_obj.over_cost
1333+ else:
1334+ logger.notifyChannel(_("Calculate Shipping"), netsvc.LOG_WARNING, _("Unable to find rate table with Shipping Table = %s and Country = %s and Over Cost > 0."%(config_obj.rate_card_id.name,address.country_id.name)))
1335+
1336+ elif config_obj.calc_method == 'state_zone_weight':
1337+ zone_pool = self.pool.get('ups.zone.map')
1338+ zone_id = zone_pool.search(cr,uid,[('rate_config_id','=',config_obj.id),('state_id','=',address.state_id.id),])
1339+ if zone_id:
1340+ zone = zone_pool.read(cr,uid,zone_id,['zone'])[0]['zone']
1341+ table_id = table_pool.search(cr,uid,[('card_id','=',config_obj.rate_card_id.id),('zone','=',zone),])
1342+ if table_id:
1343+ table_obj = table_pool.browse(cr,uid,table_id)[0]
1344+ weight = model_obj.total_weight_net
1345+ if table_obj.charge > 0:
1346+ cost = table_obj.charge
1347+ weight -= table_obj.to_weight
1348+ if weight>0:
1349+ cost += weight*table_obj.over_cost
1350+ else:
1351+ cost = weight*table_obj.over_cost
1352+ else:
1353+ logger.notifyChannel(_("Calculate Shipping"), netsvc.LOG_WARNING, _("Unable to find rate table with Shipping Table = %s and Zone = %s."%(config_obj.shipmethodname,zone)))
1354+ else:
1355+ logger.notifyChannel(_("Calculate Shipping"), netsvc.LOG_WARNING, _("Unable to find Zone Mapping Table with Shipping Rate Configuration = %s and State = %s."%(config_obj.shipmethodname,address.state_id.name)))
1356+ elif config_obj.calc_method == 'manual':
1357+ cost = 0.0
1358+ return cost
1359+
1360+ def onchange_select_ups(self, cr, uid, ids, name, last_used, context={}):
1361+ '''
1362+ Function to update shipping charge when clicking on different types of shipping method
1363+ '''
1364+ new_list = []
1365+ new_last_used = last_used
1366+ cost = 0
1367+ account_id = False
1368+ ret = {}
1369+ ship_conf_obj = self.pool.get('shipping.rate.config')
1370+ ship_conf_ids = ship_conf_obj.search(cr,uid,[])
1371+ if context.get('active_model',False) == 'sale.order' and context.get('active_id',False):
1372+ if name and len(name) == len(ship_conf_ids):
1373+ new_last_used = ''
1374+ value = 0
1375+ for line in name:
1376+ if line[2]['shipmethodname'] == last_used:
1377+ line[2]['use'] = 0
1378+ line[2]['shipmethodname'] and new_list.append(line[2])
1379+ if line[2]['use']:
1380+ new_last_used = line[2]['shipmethodname']
1381+ account_id = line[2]['account_id']
1382+ sale_id = context.get('active_id',False)
1383+ sale_order = self.pool.get('sale.order').browse(cr,uid,sale_id,context=context)
1384+ cr.execute('select type,id from res_partner_address where partner_id IN %s',(tuple([sale_order.partner_id.id]),))
1385+ res = cr.fetchall()
1386+ adr = dict(res)
1387+ if adr:
1388+ if adr.get('delivery',False):
1389+ adr_id = adr['delivery']
1390+ elif adr.get('default',False):
1391+ adr_id = adr['default']
1392+ else:
1393+ adr_id = adr.values()[0]
1394+ address = self.pool.get('res.partner.address').browse(cr, uid,adr_id,context=context)
1395+ config_id = line[2]['real_id']
1396+ cost=self.find_cost(cr, uid, config_id, address,sale_order, type='sale_order', context=context)
1397+ ret = {'value':{'shipping_cost':cost,'last_used':new_last_used,'name':new_list,'account_id':account_id}}
1398+ elif len(name) > len(ship_conf_ids):
1399+ for ship_conf in ship_conf_obj.browse(cr,uid,ship_conf_ids):
1400+ new_list.append({'shipmethodname':ship_conf.shipmethodname,'use': 0})
1401+ ret = {'value':{'last_used':new_last_used,'name':new_list}}
1402+ elif context.get('active_model',False) == 'account.invoice' and context.get('active_id',False):
1403+ if name and len(name) == len(ship_conf_ids):
1404+ new_last_used = ''
1405+ value = 0
1406+ for line in name:
1407+ if line[2]['shipmethodname'] == last_used:
1408+ line[2]['use'] = 0
1409+ line[2]['shipmethodname'] and new_list.append(line[2])
1410+ if line[2]['use']:
1411+ new_last_used = line[2]['shipmethodname']
1412+ account_id = line[2]['account_id']
1413+ invoice_id = context.get('active_id',False)
1414+ invoice = self.pool.get('account.invoice').browse(cr,uid,invoice_id,context=context)
1415+ cr.execute('select type,id from res_partner_address where partner_id IN %s',(tuple([invoice.partner_id.id]),))
1416+ res = cr.fetchall()
1417+ adr = dict(res)
1418+ if adr:
1419+ if adr.get('delivery',False):
1420+ adr_id = adr['delivery']
1421+ elif adr.get('default',False):
1422+ adr_id = adr['default']
1423+ else:
1424+ adr_id = adr.values()[0]
1425+ address = self.pool.get('res.partner.address').browse(cr, uid,adr_id,context=context)
1426+ config_id = line[2]['real_id']
1427+ cost=self.find_cost(cr, uid, config_id, address,invoice, type='invoice', context=context)
1428+ ret = {'value':{'shipping_cost':cost,'last_used':new_last_used,'name':new_list,'account_id':account_id,}}
1429+ elif len(name) > len(ship_conf_ids):
1430+ for ship_conf in ship_conf_obj.browse(cr,uid,ship_conf_ids):
1431+ new_list.append({'shipmethodname':ship_conf.shipmethodname,'use': 0})
1432+ ret = {'value':{'last_used':new_last_used,'name':new_list}}
1433+ return ret
1434+
1435+ def onchange_select(self, cr, uid, ids, name, last_used, rate_select, context={}):
1436+ new_list = []
1437+ ship_conf_obj = self.pool.get('shipping.rate.config')
1438+ ship_conf_ids = ship_conf_obj.search(cr,uid,[])
1439+ account_id = False
1440+ for line in ship_conf_obj.browse(cr,uid,ship_conf_ids):
1441+ use = 0
1442+ if line.id == rate_select:
1443+ use=1
1444+ new_list.append((0,0,{'use':use,'real_id':line.id,'account_id':line.account_id.id,'shipmethodname':line.shipmethodname}))
1445+ ret = self.onchange_select_ups(cr, uid, ids, new_list, last_used, context=context)
1446+ return ret
1447+
1448+shipping_rate_wizard()
1449+
1450+
1451+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1452
1453=== added file 'sale_negotiated_shipping/wizard/wizard_shipping_rate_view.xml'
1454--- sale_negotiated_shipping/wizard/wizard_shipping_rate_view.xml 1970-01-01 00:00:00 +0000
1455+++ sale_negotiated_shipping/wizard/wizard_shipping_rate_view.xml 2011-10-06 16:09:21 +0000
1456@@ -0,0 +1,36 @@
1457+<?xml version="1.0" encoding="utf-8"?>
1458+<openerp>
1459+ <data>
1460+ <!-- Shipping rate wizard -->
1461+ <record id="view_for_shipping_rate_wizard" model="ir.ui.view">
1462+ <field name="name">action_for_shipping_rate_wizard</field>
1463+ <field name="model">shipping.rate.wizard</field>
1464+ <field name="type">form</field>
1465+ <field name="arch" type="xml">
1466+ <form string="Shipping Method" >
1467+ <group colspan="1" col="2">
1468+ <newline/>
1469+ <field name="last_used" invisible="1"/>
1470+ <field name="account_id" invisible="1"/>
1471+ <newline/>
1472+ <field name="rate_select" string="Shipping Method" on_change="onchange_select(name,last_used,rate_select,context)" widget="selection" colspan="1"/>
1473+ <field name="shipping_cost" colspan="1"/>
1474+ <newline/>
1475+ <button special="cancel" string="Cancel" icon="gtk-close"/>
1476+ <button name="update_sale_order" string="OK" type="object" icon="gtk-ok" />
1477+ </group>
1478+ </form>
1479+ </field>
1480+ </record>
1481+
1482+
1483+ <record id="action_view_for_shipping_rate_wizard" model="ir.actions.act_window">
1484+ <field name="name">action_for_shipping_rate_wizard</field>
1485+ <field name="type">ir.actions.act_window</field>
1486+ <field name="res_model">shipping.rate.wizard</field>
1487+ <field name="view_type">form</field>
1488+ <field name="view_mode">form</field>
1489+ <field name="target">new</field>
1490+ </record>
1491+ </data>
1492+</openerp>
1493\ No newline at end of file
1494
1495=== added file 'sale_negotiated_shipping/wizard_view.xml'
1496--- sale_negotiated_shipping/wizard_view.xml 1970-01-01 00:00:00 +0000
1497+++ sale_negotiated_shipping/wizard_view.xml 2011-10-06 16:09:21 +0000
1498@@ -0,0 +1,10 @@
1499+<?xml version="1.0" encoding="utf-8"?>
1500+<openerp>
1501+ <data>
1502+ <wizard id="assigned_picker_order_id" model="stock.picking"
1503+ multi="True" name="assigned_picker_order" string="Assigned Picker"/>
1504+
1505+ <wizard id="assigned_picker_move_id" model="stock.move"
1506+ multi="True" name="assigned_picker_order" string="Assigned Picker"/>
1507+ </data>
1508+</openerp>

Subscribers

People subscribed via source and target branches

to all changes: