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
=== added directory 'sale_negotiated_shipping'
=== added file 'sale_negotiated_shipping/Change Log.txt'
--- sale_negotiated_shipping/Change Log.txt 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/Change Log.txt 2011-10-06 16:09:21 +0000
@@ -0,0 +1,18 @@
1===============================================================================
2 Version Change Log (sale_negotiated_shipping)
3===============================================================================
4 1.4 -> 1.5 (by Vinod on 19 Sept. 2011)
5 * Calculation of tax for shipment in invoice and sale order.
6
7 1.3 -> 1.4 (by Jabir on 28 June 2011)
8 * Consider shipping charge on invoice refund
9 1.2 -> 1.3 (by Jabir on 6 June 2011)
10 * Created account moves for shipping charge
11 1.1 -> 1.2
12 * Wizard to calculate shipping rate
13 * Added total weight, shipping charge, shipping method and ship calculation button on invoice view
14 * Renaming Untaxed to Net Total on invoice view
15 * Adds button in Sale order form to invoke wizard to calculate the shipping rate
16 * Added shipping method on delivery order and delivery products
17 * Adds fields Zone, State and Rate configuration to Ups Zone Map tree view form view and menu
18 * Added menu view and menu for Shipping Rate Configuration,Shipping Rate Card and Ups Shipping Rate
0\ No newline at end of file19\ No newline at end of file
120
=== added file 'sale_negotiated_shipping/__init__.py'
--- sale_negotiated_shipping/__init__.py 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/__init__.py 2011-10-06 16:09:21 +0000
@@ -0,0 +1,27 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22
23import sale_negotiate
24import shipping_rate_table
25import invoice_weight
26import wizard
27# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file28\ No newline at end of file
129
=== added file 'sale_negotiated_shipping/__openerp__.py'
--- sale_negotiated_shipping/__openerp__.py 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/__openerp__.py 2011-10-06 16:09:21 +0000
@@ -0,0 +1,44 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22
23{
24 'name': 'Zip',
25 'version': '1.5',
26 'category': 'Generic Modules/Others',
27 'description': """
28 """,
29 'author': 'NovaPoint Group LLC',
30 'website': ' http://www.novapointgroup.com',
31 'depends': ['base','sale','sale_weight'],
32 'init_xml': [],
33 'update_xml': [
34 'shipping_rate_table_view.xml' ,
35 'wizard/wizard_shipping_rate_view.xml',
36 'sale_negotiate_view.xml',
37 'security/ir.model.access.csv',
38 'invoice_view.xml',],
39 'demo_xml': [
40 ],
41 'installable': True,
42 'active': False,
43}
44# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
045
=== added file 'sale_negotiated_shipping/invoice_view.xml'
--- sale_negotiated_shipping/invoice_view.xml 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/invoice_view.xml 2011-10-06 16:09:21 +0000
@@ -0,0 +1,73 @@
1<?xml version="1.0"?>
2<openerp>
3 <data>
4
5 <!--Invoice Form -->
6 <record id="invoice_form_inherit_1" model="ir.ui.view">
7 <field name="name">account.invoice.form.inherit</field>
8 <field name="model">account.invoice</field>
9 <field name="inherit_id" ref="account.invoice_form"/>
10 <field name="type">form</field>
11 <field name="arch" type="xml">
12 <xpath expr="//label[@string='']" position="replace">
13 <field name="total_weight_net"/>
14 <field name="shipcharge"/>
15 <field name="ship_method"/>
16 </xpath>
17 <xpath expr="//button[@name='button_reset_taxes']" position="replace">
18 <button colspan="1" name="button_reset_taxes" states="draft" string="Compute Taxes" type="object" groups="base.group_user" icon="terp-stock_format-scientific"/>
19 <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" />
20 </xpath>
21
22 </field>
23 </record>
24 <record id="invoice_supplier_form_inherit_1" model="ir.ui.view">
25 <field name="name">account.invoice.supplier.form.inherit</field>
26 <field name="model">account.invoice</field>
27 <field name="inherit_id" ref="account.invoice_supplier_form"/>
28 <field name="type">form</field>
29 <field name="arch" type="xml">
30 <xpath expr="//label[@string='']" position="replace">
31 <field name="total_weight_net"/>
32 <field name="shipcharge"/>
33 <field name="ship_method"/>
34 </xpath>
35 <xpath expr="//button[@name='button_reset_taxes']" position="replace">
36 <button colspan="1" name="button_reset_taxes" states="draft" string="Compute Taxes" type="object" groups="base.group_user" icon="terp-stock_format-scientific"/>
37 <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" />
38 </xpath>
39
40 </field>
41 </record>
42
43
44 <!-- Renaming Untaxed to Net Total on invoice view-->
45
46 <record id="account_invoice_view_changes_form_inherit01" model="ir.ui.view">
47 <field name="name">account_invoice_view_changes_form_inherit01</field>
48 <field name="model">account.invoice</field>
49 <field name="type">form</field>
50 <field name="inherit_id" ref="account.invoice_form"/>
51 <field name="arch" type="xml">
52 <xpath expr="//field[@name='amount_untaxed']" position="replace">
53 <field name="amount_untaxed" string="Net Total"/>
54 </xpath>
55
56 </field>
57 </record>
58 <record id="invoice_supplier_form_inherit01" model="ir.ui.view">
59 <field name="name">invoice_supplier_form_inherit01</field>
60 <field name="model">account.invoice</field>
61 <field name="type">form</field>
62 <field name="inherit_id" ref="account.invoice_supplier_form"/>
63 <field name="arch" type="xml">
64 <xpath expr="//field[@name='amount_untaxed']" position="replace">
65 <field name="amount_untaxed" string="Net Total"/>
66 </xpath>
67
68 </field>
69 </record>
70
71
72 </data>
73</openerp>
0\ No newline at end of file74\ No newline at end of file
175
=== added file 'sale_negotiated_shipping/invoice_weight.py'
--- sale_negotiated_shipping/invoice_weight.py 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/invoice_weight.py 2011-10-06 16:09:21 +0000
@@ -0,0 +1,201 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22
23"""Compute the net weight of sale orders."""
24
25from osv import osv, fields
26import decimal_precision as dp
27import time
28
29class account_invoice(osv.osv):
30 """Add the total net weight to the object "Sale Order"."""
31
32 _inherit = "account.invoice"
33
34 def _total_weight_net(self, cr, uid, ids, field_name, arg, context):
35 """Compute the total net weight of the given Invoice."""
36 result = {}
37 for invoice in self.browse(cr, uid, ids, context=context):
38 result[invoice.id] = 0.0
39 for line in invoice.invoice_line:
40 if line.product_id:
41 result[invoice.id] += line.weight_net or 0.0
42 return result
43
44 def _get_invoice(self, cr, uid, ids, context={}):
45 """Get the invoice ids of the given Invoice Lines."""
46 result = {}
47 for line in self.pool.get('account.invoice.line').browse(cr, uid, ids,
48 context=context):
49 result[line.invoice_id.id] = True
50 return result.keys()
51
52 def _amount_shipment_tax(self, cr, uid, shipment_taxes, shipment_charge):
53 val = 0.0
54 for c in self.pool.get('account.tax').compute_all(cr, uid, shipment_taxes, shipment_charge, 1)['taxes']:
55 val += c.get('amount', 0.0)
56 return val
57
58 def _amount_all(self, cr, uid, ids, name, args, context=None):
59 res = super(account_invoice, self)._amount_all(cr, uid, ids, name, args, context=context)
60 for invoice in self.browse(cr, uid, ids, context=context):
61 if invoice.ship_method_id:
62 res[invoice.id]['amount_total'] = res[invoice.id]['amount_untaxed'] + res[invoice.id]['amount_tax'] + invoice.shipcharge
63 return res
64
65 def _get_invoice_tax(self, cr, uid, ids, context=None):
66 invoice = self.pool.get('account.invoice')
67 return super(account_invoice, invoice)._get_invoice_tax(cr, uid, ids, context=context)
68
69 def _get_invoice_line(self, cr, uid, ids, context=None):
70 invoice = self.pool.get('account.invoice')
71 return super(account_invoice, invoice)._get_invoice_line(cr, uid, ids, context=context)
72
73 def _get_invoice_from_line(self, cr, uid, ids, context=None):
74 invoice = self.pool.get('account.invoice')
75 return super(account_invoice, invoice)._get_invoice_from_line(cr, uid, ids, context=context)
76
77 def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines):
78 """finalize_invoice_move_lines(cr, uid, invoice, move_lines) -> move_lines
79 Hook method to be overridden in additional modules to verify and possibly alter the
80 move lines to be created by an invoice, for special cases.
81 :param invoice_browse: browsable record of the invoice that is generating the move lines
82 :param move_lines: list of dictionaries with the account.move.lines (as for create())
83 :return: the (possibly updated) final move_lines to create for this invoice
84 """
85 move_lines = super(account_invoice, self).finalize_invoice_move_lines(cr, uid, invoice_browse, move_lines)
86 if invoice_browse.type == "out_refund":
87 account = invoice_browse.account_id.id
88 else:
89 account = invoice_browse.sale_account_id.id
90 if invoice_browse.sale_account_id and invoice_browse.shipcharge:
91 lines1={
92 'analytic_account_id' : False,
93 'tax_code_id' : False,
94 'analytic_lines' : [],
95 'tax_amount' : False,
96 'name' : 'Shipping Charge',
97 'ref' : '',
98 'currency_id' : False,
99 'credit' : invoice_browse.shipcharge,
100 'product_id' : False,
101 'date_maturity' : False,
102 'debit' : False,
103 'date' : time.strftime("%Y-%m-%d"),
104 'amount_currency' : 0,
105 'product_uom_id' : False,
106 'quantity' : 1,
107 'partner_id' : invoice_browse.partner_id.id,
108 'account_id' : account,}
109
110 move_lines.append((0,0,lines1))
111 # Retrieve the existing debit line if one exists
112 has_entry = False
113 for move_line in move_lines:
114 journal_entry = move_line[2]
115 if journal_entry['account_id'] == invoice_browse.journal_id.default_debit_account_id.id:
116 journal_entry['debit'] += invoice_browse.shipcharge
117 has_entry = True
118 break
119 # If debit line does not exist create one. Generally this condition will not happen. Just a fail-safe option
120 if not has_entry:
121 lines2={
122 'analytic_account_id' : False,
123 'tax_code_id' : False,
124 'analytic_lines' : [],
125 'tax_amount' : False,
126 'name' : '/',
127 'ref' : '',
128 'currency_id' : False,
129 'credit' : False,
130 'product_id' : False,
131 'date_maturity' : False,
132 'debit' : invoice_browse.shipcharge,
133 'date' : time.strftime("%Y-%m-%d"),
134 'amount_currency' : 0,
135 'product_uom_id' : False,
136 'quantity' : 1,
137 'partner_id' : invoice_browse.partner_id.id,
138 'account_id' : invoice_browse.journal_id.default_debit_account_id.id,}
139
140 move_lines.append((0,0,lines2))
141 return move_lines
142
143
144
145
146 _columns = {
147
148 'amount_total': fields.function(_amount_all, method=True, digits_compute=dp.get_precision('Account'), string='Total',
149 store={
150 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line','shipcharge'], -10),
151 'account.invoice.tax': (_get_invoice_tax, None, -10),
152 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], -10),
153 }, multi='all'),
154
155 'total_weight_net': fields.function(_total_weight_net, method=True,
156 readonly=True, string='Total Net Weight',
157 help="The cumulated net weight of all the invoice lines.",
158 store={
159 # Low priority to compute this before fields in other modules
160 'account.invoice': (lambda self, cr, uid, ids, c={}: ids,
161 ['invoice_line'], 10),
162 'account.invoice.line': (_get_invoice,
163 ['quantity', 'product_id'], 10),
164 },
165 ),
166 'shipcharge': fields.float('Shipping Cost', readonly=True),
167 'ship_method': fields.char('Shipping Method',size=128, readonly=True),
168 'ship_method_id': fields.many2one('shipping.rate.config','Shipping Method', readonly=True),
169 'sale_account_id':fields.many2one('account.account','Shipping Account',help='This account represents the g/l account for booking shipping income.', readonly=True)
170
171 }
172account_invoice()
173
174# Record the net weight of the order line
175class invoice_line(osv.osv):
176 """Add the net weight to the object "Invoice Line"."""
177 _inherit = 'account.invoice.line'
178
179 def _weight_net(self, cr, uid, ids, field_name, arg, context):
180 """Compute the net weight of the given Invoice Lines."""
181 result = {}
182 for line in self.browse(cr, uid, ids, context=context):
183 result[line.id] = 0.0
184
185 if line.product_id:
186 result[line.id] += (line.product_id.weight_net
187 * line.quantity)# / line.product_uom.factor)
188 return result
189 _columns = {
190 'weight_net': fields.function(_weight_net, method=True,
191 readonly=True, string='Net Weight', help="The net weight in Kg.",
192 store={
193 # Low priority to compute this before fields in other modules
194 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids,
195 ['quantity', 'product_id'], -11),
196 },
197 ),
198
199 }
200invoice_line()
201# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0202
=== added file 'sale_negotiated_shipping/sale_negotiate.py'
--- sale_negotiated_shipping/sale_negotiate.py 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/sale_negotiate.py 2011-10-06 16:09:21 +0000
@@ -0,0 +1,106 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22from osv import fields,osv
23import decimal_precision as dp
24import time
25
26#Shipping rate configuration model
27class shipping_rate_config(osv.osv):
28 _name = 'shipping.rate.config'
29 _description = "Configuration for shipping rate"
30 _rec_name = 'shipmethodname'
31 _columns = {
32 'real_id':fields.integer('ID',readonly=True, ),
33 'shipmethodname':fields.char('Shipping Method Name',size=128,help='Shipping method name. Displayed in the wizard.'),
34 'active':fields.boolean('Active',help='Indicates whether a shipping method is active'),
35 'use':fields.boolean('Select',),
36 '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.'),
37 'ups_shipping_wizard': fields.integer('Shipping Wizard'),
38 'rate_card_id':fields.many2one('ups.shipping.rate.card','Shipping Rate Card'),
39 'zone_map_ids':fields.one2many('ups.zone.map','rate_config_id','Zone Map'),
40 'account_id':fields.many2one('account.account','Account',help='This account represents the g/l account for booking shipping income.'),
41 # Added to include tax configuration for shipment
42 'shipment_tax_ids': fields.many2many('account.tax', 'shipment_tax_rel', 'shipment_id', 'tax_id', 'Taxes', domain=[('parent_id','=',False)]),
43 }
44 _defaults = {
45 'calc_method':'country_weight'
46 }
47
48shipping_rate_config()
49
50# State - Zone table
51class zone_map(osv.osv):
52 _name = 'ups.zone.map'
53 _description = "Zone Mapping Table"
54 _rec_name = 'zone'
55 _columns = {
56 'zone':fields.integer('Zone'),
57 'state_id':fields.many2one('res.country.state','State / Zone'),
58 'rate_config_id':fields.many2one('shipping.rate.config','Shipping Rate Configuration')
59 }
60
61zone_map()
62'''
63Adding shipping method field on delivery order and delivery products
64'''
65class stock_picking(osv.osv):
66
67 _inherit = "stock.picking"
68 def _get_sale_order(self, cr, uid, ids, context={}):
69 result = []
70 for id in ids:
71 stock_pick_ids = self.pool.get('stock.picking').search(cr,uid,[('sale_id','=',id)])
72 result += stock_pick_ids
73 result = list(set(result))
74 return result
75 _columns = {
76 'ship_method': fields.related('sale_id', 'ship_method', string='Shipping Method', type='char', size=128, #store=True
77 store={
78 'sale.order': (_get_sale_order, ['ship_method'], -10),}
79 ),
80 }
81
82stock_picking()
83class stock_move(osv.osv):
84
85 _inherit = "stock.move"
86
87 def _get_sale_order(self, cr, uid, ids, context={}):
88 result = []
89 move_ids = []
90 for id in ids:
91 stock_pick_ids = self.pool.get('stock.picking').search(cr,uid,[('sale_id','=',id)])
92 if stock_pick_ids:
93 move_ids += self.pool.get('stock.move').search(cr,uid,[('picking_id','in',stock_pick_ids)])
94 move_ids = list(set(move_ids))
95 return move_ids
96 _columns = {
97 'ship_method': fields.related('picking_id','sale_id', 'ship_method', string='Shipping Method', type='char', size=128,# store=True
98 store={
99 'sale.order': (_get_sale_order, ['ship_method'], -10),}
100 ),
101 }
102
103stock_move()
104
105# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
106
0107
=== added file 'sale_negotiated_shipping/sale_negotiate_view.xml'
--- sale_negotiated_shipping/sale_negotiate_view.xml 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/sale_negotiate_view.xml 2011-10-06 16:09:21 +0000
@@ -0,0 +1,184 @@
1<?xml version="1.0"?>
2<openerp>
3 <data>
4 <!--Sale order form-->
5
6 <!--Adds button in Sale order form to invoke wizard to calculate the shipping rate-->
7 <record model="ir.ui.view" id="sale_weight_form_inherit">
8 <field name="name">sale_weight.view_form.inherit</field>
9 <field name="model">sale.order</field>
10 <field name="inherit_id" ref="sale_weight.sale_weight_form" />
11 <field name="type">form</field>
12 <field name="arch" type="xml">
13 <field name="total_weight_net" position="replace"/>
14 </field>
15 </record>
16
17
18 <record id="view_sale_order_inherit_1" model="ir.ui.view">
19 <field name="name">view_sale_order_inherit_1</field>
20 <field name="model">sale.order</field>
21 <field name="inherit_id" ref="sale.view_order_form"/>
22 <field name="type">form</field>
23 <field name="arch" type="xml">
24
25 <xpath expr="//group[@colspan='10']" position="replace">
26 <button name="button_dummy" states="draft" string="Compute" type="object" icon="gtk-execute" colspan="2"/>
27 <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" />
28 <group col="1" colspan="2">
29 <field name="ship_method"/>
30 <field name="total_weight_net" />
31 </group>
32 <group col="2" colspan="2">
33 <field name="amount_untaxed" sum="Net Total" string="Net Total"/>
34 <field name="shipcharge" help="The shipping charge on this order."/>
35 <field name="amount_tax"/>
36 <field name="amount_total"/>
37 <label colspan="1"/><button name="%(sale.action_view_sale_advance_payment_inv)d" string="Advance Invoice"
38 type="action" icon="gtk-execute" states="draft,manual" groups="base.group_extended"/>
39 </group>
40
41
42 </xpath>
43 </field>
44 </record>
45 <!-- Delivery Orders -->
46 <!-- Form -->
47 <record id="view_picking_out_form_inherit" model="ir.ui.view">
48 <field name="name">stock.picking.out.form.inherit</field>
49 <field name="model">stock.picking</field>
50 <field name="inherit_id" ref="stock.view_picking_out_form"/>
51 <field name="type">form</field>
52 <field name="arch" type="xml">
53 <xpath expr="//field[@name='company_id']" position="after">
54 <field name="ship_method"/>
55 </xpath>
56 </field>
57 </record>
58 <!-- Tree -->
59 <record id="view_picking_out_tree_inherit" model="ir.ui.view">
60 <field name="name">stock.picking.out.tree.inherit</field>
61 <field name="model">stock.picking</field>
62 <field name="inherit_id" ref="stock.view_picking_out_tree"/>
63 <field name="type">tree</field>
64 <field name="arch" type="xml">
65 <xpath expr="//field[@name='backorder_id']" position="before">
66 <field name="ship_method"/>
67 </xpath>
68 </field>
69 </record>
70 <!-- Search -->
71 <record id="view_picking_internal_search_inherit" model="ir.ui.view">
72 <field name="name">stock.picking.internal.search.inherit</field>
73 <field name="model">stock.picking</field>
74 <field name="type">search</field>
75 <field name="inherit_id" ref="stock.view_picking_out_search"/>
76 <field name="arch" type="xml">
77 <xpath expr="//filter[@string='Journal']" position="after">
78 <separator orientation="vertical" />
79 <filter string="Shipping Method" icon="terp-product" domain="[]" context="{'group_by':'ship_method'}" groups="base.group_extended"/>
80 </xpath>
81 </field>
82 </record>
83
84
85 <!-- Deliver Products -->
86 <!-- Tree -->
87 <record id="view_move_tree_reception_picking_inherit" model="ir.ui.view">
88 <field name="name">stock.move.tree2.inherit</field>
89 <field name="model">stock.move</field>
90 <field name="type">tree</field>
91 <field name="inherit_id" ref="stock.view_move_tree_reception_picking"/>
92 <field name="priority" eval="6" />
93 <field name="arch" type="xml">
94 <xpath expr="//field[@name='date']" position="after">
95 <field name="ship_method"/>
96 </xpath>
97 </field>
98 </record>
99
100 <!-- Form -->
101 <record id="view_move_form_inherit" model="ir.ui.view">
102 <field name="name">stock.move.form.inherit</field>
103 <field name="model">stock.move</field>
104 <field name="type">form</field>
105 <field name="inherit_id" ref="stock.view_move_form"/>
106 <field name="arch" type="xml">
107 <xpath expr="//group[@col='4']" position="after">
108 <group colspan="2" col="2" groups="base.group_extended">
109 <separator string="Shipping" colspan="4" groups="base.group_extended"/>
110 <field name="ship_method" readonly="1"/>
111 </group>
112 </xpath>
113 </field>
114 </record>
115 <!-- Search -->
116 <record id="view_move_search_reception_outcoming_picking_inherit" model="ir.ui.view">
117 <field name="name">stock.move.outgoing.search2.inherit</field>
118 <field name="model">stock.move</field>
119 <field name="type">search</field>
120 <field name="inherit_id" ref="stock.view_move_search_reception_outcoming_picking"/>
121 <field eval="8" name="priority"/>
122 <field name="arch" type="xml">
123 <xpath expr="//filter[@string='Order Date']" position="after">
124 <separator orientation="vertical" />
125 <filter string="Shipping Method" icon="terp-product" domain="[]" context="{'group_by':'ship_method'}" groups="base.group_extended"/>
126 </xpath>
127 </field>
128 </record>
129
130 <!--Zone Map Tree View-->
131
132 <!-- Adds fields Zone, State and Rate configuration to Ups Zone Map Tree View -->
133
134 <record id="zone_map_tree" model="ir.ui.view">
135 <field name="name">ups.zone.map.tree</field>
136 <field name="model">ups.zone.map</field>
137 <field name="type">tree</field>
138 <field name="arch" type="xml">
139 <tree string='Zone Map'>
140 <field name="zone" select="1"/>
141 <field name="state_id" select="1"/>
142 <field name="rate_config_id" select="1"/>
143 </tree>
144 </field>
145 </record>
146
147 <!--Zone Map Form-->
148
149 <!--Adds fields Zone, State and Rate configuration to Ups Zone Map Form View-->
150
151 <record id="zone_map_form" model="ir.ui.view">
152 <field name="name">ups.zone.map.form</field>
153 <field name="model">ups.zone.map</field>
154 <field name="type">form</field>
155 <field name="arch" type="xml">
156 <form string='Zone Map'>
157 <field name="zone" select="1"/>
158 <field name="state_id" select="1"/>
159 <field name="rate_config_id" select="1"/>
160 </form>
161 </field>
162 </record>
163
164 <!--Zone Map Action Record -->
165
166 <record id="zone_map_action" model="ir.actions.act_window">
167 <field name="name">Zone Map</field>
168 <field name="res_model">ups.zone.map</field>
169 <field name="view_type">form</field>
170 <field name="view_mode">tree,form</field>
171 <field name="view_id" ref="zone_map_tree"/>
172 </record>
173
174 <!-- Menu item for for Zone Map under the Menu Localisation-->
175
176 <menuitem
177 id="zone_map_menu"
178 name="Zone Map"
179 parent="negotiated_shipping_config"
180 action="zone_map_action" />
181
182
183 </data>
184</openerp>
0\ No newline at end of file185\ No newline at end of file
1186
=== added directory 'sale_negotiated_shipping/security'
=== added file 'sale_negotiated_shipping/security/ir.model.access.csv'
--- sale_negotiated_shipping/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/security/ir.model.access.csv 2011-10-06 16:09:21 +0000
@@ -0,0 +1,17 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2"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
3"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
4"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
5,,,,,,,
6"security_ups_shipping_rate_salesman","security.ups.shipping.rate.salesman","model_ups_shipping_rate","base.group_sale_salesman",1,1,0,0
7"security_ups_shipping_rate_erp_manager","security.ups.shipping.rate.erp.manager","model_ups_shipping_rate","base.group_erp_manager",1,1,1,1
8"security_ups_shipping_rate_manager","security.ups.shipping.rate.manager","model_ups_shipping_rate","base.group_sale_manager",1,1,1,1
9,,,,,,,
10"security_ups_shipping_rate_config_salesman","security.ups.shipping.rate.config.salesman","model_shipping_rate_config","base.group_sale_salesman",1,1,0,0
11"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
12"security_ups_shipping_rate_config_manager","security.ups.shipping.rate.config.manager","model_shipping_rate_config","base.group_sale_manager",1,1,1,1
13,,,,,,,
14"security_ups_zone_map_salesman","security.ups.zone.map.salesman","model_ups_zone_map","base.group_sale_salesman",1,1,0,0
15"security_ups_zone_map_erp_manager","security.ups.zone.map.erp.manager","model_ups_zone_map","base.group_erp_manager",1,1,1,1
16"security_ups_zone_map_manager","security.ups.zone.map.manager","model_ups_zone_map","base.group_sale_manager",1,1,1,1
17
018
=== added file 'sale_negotiated_shipping/security/sale_security.xml'
--- sale_negotiated_shipping/security/sale_security.xml 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/security/sale_security.xml 2011-10-06 16:09:21 +0000
@@ -0,0 +1,13 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="0">
4
5 <record id="group_shipping_manager" model="res.groups">
6 <field name="name">Shipping / Manager</field>
7 </record>
8 <record id="group_shipping_user" model="res.groups">
9 <field name="name">Shipping / User</field>
10 </record>
11
12 </data>
13</openerp>
014
=== added file 'sale_negotiated_shipping/shipping_rate_table.py'
--- sale_negotiated_shipping/shipping_rate_table.py 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/shipping_rate_table.py 2011-10-06 16:09:21 +0000
@@ -0,0 +1,175 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22from osv import fields,osv
23import decimal_precision as dp
24import time
25
26
27class shipping_rate_card(osv.osv):
28 _name = 'ups.shipping.rate.card'
29 _description = "Ground Shipping Calculation Table"
30 _columns = {
31 'name':fields.char('Shipping Method',size=128,required=True),
32 'from_date':fields.datetime('From Date', ),
33 'to_date':fields.datetime('To Date', ),
34 'rate_ids': fields.one2many('ups.shipping.rate','card_id','Shipping Rates', required=True),
35 }
36
37shipping_rate_card()
38
39class shipping_rate(osv.osv):
40 _name = 'ups.shipping.rate'
41 _description = "Shipping Calculation Table"
42 _columns = {
43 'name':fields.char('Shipping Method',size=128),
44 'from_weight': fields.integer('From Weight', required=True),
45 'to_weight': fields.integer('To Weight'),
46 'charge': fields.float('Shipping Charge'),
47 'over_cost': fields.float('Shipping Charge per pound over'),
48 'country_id':fields.many2one('res.country','Country'),
49 'zone':fields.integer('Zone', required=True),
50 'card_id':fields.many2one('ups.shipping.rate.card','Shipping Table')
51 }
52
53shipping_rate()
54
55class sale_order(osv.osv):
56 _name = "sale.order"
57 _inherit="sale.order"
58 _description = "Sale Order"
59
60 def _make_invoice(self, cr, uid, order, lines, context=None):
61 inv_id = super(sale_order, self)._make_invoice(cr, uid, order, lines, context=None)
62 if inv_id and order._table_name == 'sale.order':
63 if order.sale_account_id:
64 self.pool.get('account.invoice').write(cr,uid,inv_id,{
65 'shipcharge':order.shipcharge,
66 'ship_method':order.ship_method,
67 'ship_method_id':order.ship_method_id.id,
68 'sale_account_id':order.sale_account_id.id,
69 })
70 self.pool.get('account.invoice').button_reset_taxes(cr, uid, [inv_id], context=context)
71
72 return inv_id
73
74 def _get_order(self, cr, uid, ids, context=None):
75 return super(sale_order, self)._get_order(cr, uid, ids, context=context)
76
77 def _amount_shipment_tax(self, cr, uid, shipment_taxes, shipment_charge):
78 val = 0.0
79 for c in self.pool.get('account.tax').compute_all(cr, uid, shipment_taxes, shipment_charge, 1)['taxes']:
80 val += c.get('amount', 0.0)
81 return val
82
83 def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
84 cur_obj = self.pool.get('res.currency')
85 res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context=context)
86 for order in self.browse(cr, uid, ids, context=context):
87 cur = order.pricelist_id.currency_id
88 if order.ship_method_id:
89 if order.ship_method_id.shipment_tax_ids and len(order.ship_method_id.shipment_tax_ids) > 0:
90 val = self._amount_shipment_tax(cr, uid, order.ship_method_id.shipment_tax_ids, order.shipcharge)
91 res[order.id]['amount_tax'] += cur_obj.round(cr, uid, cur, val)
92 res[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] + order.shipcharge
93 return res
94
95 _columns = {
96 'shipcharge': fields.float('Shipping Cost', readonly=True),
97 'ship_method': fields.char('Shipping Method',size=128, readonly=True),
98 'ship_method_id': fields.many2one('shipping.rate.config','Shipping Method', readonly=True),
99 'sale_account_id':fields.many2one('account.account','Shipping Account',help='This account represents the g/l account for booking shipping income.', readonly=True),
100 'amount_untaxed': fields.function(_amount_all, method=True, digits_compute= dp.get_precision('Sale Price'), string='Untaxed Amount',
101 store = {
102 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'ship_method_id'], 10),
103 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
104 },
105 multi='sums', help="The amount without tax."),
106 'amount_tax': fields.function(_amount_all, method=True, digits_compute= dp.get_precision('Sale Price'), string='Taxes',
107 store = {
108 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'ship_method_id'], 10),
109 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
110 },
111 multi='sums', help="The tax amount."),
112 'amount_total': fields.function(_amount_all, method=True, digits_compute= dp.get_precision('Sale Price'), string='Total',
113 store = {
114 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'ship_method_id'], 10),
115 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
116 },
117 multi='sums', help="The total amount."),
118 }
119
120sale_order()
121
122# Added to calculate tax for shipment in invoice
123class account_invoice_tax_inherit(osv.osv):
124 _name = "account.invoice.tax"
125 _inherit = "account.invoice.tax"
126
127 def compute(self, cr, uid, invoice_id, context=None):
128 tax_grouped = super(account_invoice_tax_inherit, self).compute(cr, uid, invoice_id, context=context)
129 tax_obj = self.pool.get('account.tax')
130 cur_obj = self.pool.get('res.currency')
131 inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context)
132 cur = inv.currency_id
133 company_currency = inv.company_id.currency_id.id
134
135 if inv.ship_method_id and inv.ship_method_id.shipment_tax_ids and len(inv.ship_method_id.shipment_tax_ids) > 0:
136 for tax in tax_obj.compute_all(cr, uid, inv.ship_method_id.shipment_tax_ids, inv.shipcharge, 1)['taxes']:
137 val={}
138 val['invoice_id'] = inv.id
139 val['name'] = tax['name']
140 val['amount'] = tax['amount']
141 val['manual'] = False
142 val['sequence'] = tax['sequence']
143 val['base'] = tax['price_unit'] * 1
144
145 if inv.type in ('out_invoice','in_invoice'):
146 val['base_code_id'] = tax['base_code_id']
147 val['tax_code_id'] = tax['tax_code_id']
148 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)
149 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)
150 val['account_id'] = tax['account_collected_id'] or line.account_id.id
151 else:
152 val['base_code_id'] = tax['ref_base_code_id']
153 val['tax_code_id'] = tax['ref_tax_code_id']
154 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)
155 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)
156 val['account_id'] = tax['account_paid_id'] or line.account_id.id
157
158 key = (val['tax_code_id'], val['base_code_id'], val['account_id'])
159 if not key in tax_grouped:
160 tax_grouped[key] = val
161 else:
162 tax_grouped[key]['amount'] += val['amount']
163 tax_grouped[key]['base'] += val['base']
164 tax_grouped[key]['base_amount'] += val['base_amount']
165 tax_grouped[key]['tax_amount'] += val['tax_amount']
166
167 for t in tax_grouped.values():
168 t['base'] = cur_obj.round(cr, uid, cur, t['base'])
169 t['amount'] = cur_obj.round(cr, uid, cur, t['amount'])
170 t['base_amount'] = cur_obj.round(cr, uid, cur, t['base_amount'])
171 t['tax_amount'] = cur_obj.round(cr, uid, cur, t['tax_amount'])
172 return tax_grouped
173
174account_invoice_tax_inherit()
175# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0176
=== added file 'sale_negotiated_shipping/shipping_rate_table_view.xml'
--- sale_negotiated_shipping/shipping_rate_table_view.xml 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/shipping_rate_table_view.xml 2011-10-06 16:09:21 +0000
@@ -0,0 +1,167 @@
1<?xml version="1.0"?>
2<openerp>
3 <data>
4 <!--Adds Menu for the Shipping Configuration-->
5 <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"/>
6
7 <!--SHIPPING RATE-->
8 <!--Tree view for Ups Shipping Rate-->
9
10 <record id="tree_view_for_shipping_rate" model="ir.ui.view">
11 <field name="name">tree.view.for.shipping.rate</field>
12 <field name="model">ups.shipping.rate</field>
13 <field name="type">tree</field>
14 <field name="arch" type="xml">
15 <tree string='Shipping Rate'>
16 <field name="name"/>
17 <field name="from_weight"/>
18 <field name="to_weight"/>
19 <field name="charge"/>
20 <field name="over_cost"/>
21 <field name="country_id"/>
22 <field name="zone"/>
23 </tree>
24 </field>
25 </record>
26
27 <!--Form view for Ups Shipping Rate-->
28
29 <record id="form_view_for_shipping_rate" model="ir.ui.view">
30 <field name="name">form.view.for.shipping.rate</field>
31 <field name="model">ups.shipping.rate</field>
32 <field name="type">form</field>
33 <field name="arch" type="xml">
34 <form string='Shipping Rate'>
35 <group colspan="4" col="4" string="">
36 <field name="name" select="1" colspan="1"/><newline/>
37 <field name="from_weight" select="1" colspan="1"/>
38 <field name="to_weight" select="1" colspan="1"/><newline/>
39 <field name="charge" select="1" colspan="1"/>
40 <field name="over_cost" select="1" colspan="1"/><label colspan="3"/><newline/>
41 <field name="country_id" select="1" colspan="1"/>
42 <field name="zone" attrs="{'invisible':[('name', '=', 'ups_ground')]}" />
43 <field name="card_id"/>
44 </group>
45 </form>
46 </field>
47 </record>
48
49
50 <!--Action Record for Shipping Rate-->
51
52 <record id="action_for_shipping_rate" model="ir.actions.act_window">
53 <field name="name">Shipping Rates</field>
54 <field name="res_model">ups.shipping.rate</field>
55 <field name="view_type">form</field>
56 <field name="view_mode">tree,form</field>
57 <field name="view_id" ref="tree_view_for_shipping_rate"/>
58 </record>
59
60 <!-- Shipping Rate menu-->
61 <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"/>
62
63 <!--SHIPPING RATE CARD-->
64 <!-- Shipping Rate Card List View-->
65
66 <record id="tree_view_shipping_rate_table" model="ir.ui.view">
67 <field name="name">tree.ups.shipping.rate.card</field>
68 <field name="model">ups.shipping.rate.card</field>
69 <field name="type">tree</field>
70 <field name="arch" type="xml">
71 <tree>
72 <field name="name" select="1"/>
73 <field name="from_date" select="1" colspan="1"/>
74 <field name="to_date" select="1" colspan="1"/>
75 </tree>
76 </field>
77 </record>
78
79 <!-- Shipping Rate Card Form View-->
80
81 <record id="form_view_shipping_rate_table" model="ir.ui.view">
82 <field name="name">form.ups.shipping.rate.card</field>
83 <field name="model">ups.shipping.rate.card</field>
84 <field name="type">form</field>
85 <field name="arch" type="xml">
86 <form>
87 <field name="name" select="1" colspan="2"/><newline/>
88 <field name="from_date" select="1" colspan="1"/>
89 <field name="to_date" select="1" colspan="1"/><newline/>
90 <separator string="Shipping Rates" colspan="4"/>
91 <field name="rate_ids" select="1" colspan="4" nolabel="1"/>
92 </form>
93 </field>
94 </record>
95
96
97 <!--Action Record for Shipping Rate Card-->
98
99 <record id="action_shipping_rate_table" model="ir.actions.act_window">
100 <field name="name">Shipping Methods</field>
101 <field name="res_model">ups.shipping.rate.card</field>
102 <field name="view_type">form</field>
103 <field name="view_mode">tree,form</field>
104 <field name="view_id" ref="tree_view_shipping_rate_table"/>
105 </record>
106 <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" />
107
108 <!--SHIPPING RATE CONFIGURATION-->
109 <!-- Shipping Rate Configuration List View-->
110 <record id="tree_view_shipping_rate_config" model="ir.ui.view">
111 <field name="name">tree.shipping.rate.config</field>
112 <field name="model">shipping.rate.config</field>
113 <field name="type">tree</field>
114 <field name="arch" type="xml">
115 <tree editable="top">
116 <field name="shipmethodname"/>
117 <field name="active" select="1"/>
118 <field name="calc_method"/>
119 <field name="rate_card_id"/>
120 <field name="account_id" required="1"/>
121
122 </tree>
123 </field>
124 </record>
125
126 <!-- Shipping Rate Configuration Form View-->
127
128 <record id="form_view_shipping_rate_config" model="ir.ui.view">
129 <field name="name">form.shipping.rate.config</field>
130 <field name="model">shipping.rate.config</field>
131 <field name="type">form</field>
132 <field name="arch" type="xml">
133 <form>
134 <field name="shipmethodname" select="1" colspan="2"/>
135 <field name="active" select="1" colspan="2"/>
136 <field name="calc_method" select="1" colspan="2"/>
137 <field name="rate_card_id" select="1" colspan="2"/>
138 <field name="account_id" select="1" colspan="2" required="1"/>
139 <field name="shipment_tax_ids" colspan="2"/>
140 <newline/>
141 <group height="425" colspan="6" col="6">
142 <field name="zone_map_ids" attrs="{'invisible':[('calc_method','!=','state_zone_weight')]}" nolabel="1">
143 <tree string="Zone Map">
144 <field name="zone"/>
145 <field name="state_id"/>
146 </tree>
147 </field>
148 </group>
149 </form>
150 </field>
151 </record>
152
153
154 <!--Action Record for Shipping Rate Configuration and Menu-->
155
156 <record id="action_shipping_rate_config" model="ir.actions.act_window">
157 <field name="name">Shipping Rate Configuration</field>
158 <field name="res_model">shipping.rate.config</field>
159 <field name="view_type">form</field>
160 <field name="view_mode">tree,form</field>
161 <field name="view_id" ref="tree_view_shipping_rate_config"/>
162 </record>
163
164 <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"/>
165
166 </data>
167</openerp>
0\ No newline at end of file168\ No newline at end of file
1169
=== added directory 'sale_negotiated_shipping/wizard'
=== added file 'sale_negotiated_shipping/wizard/__init__.py'
--- sale_negotiated_shipping/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/wizard/__init__.py 2011-10-06 16:09:21 +0000
@@ -0,0 +1,26 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22
23
24
25import wizard_shipping_rate_calculation
26# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file27\ No newline at end of file
128
=== added file 'sale_negotiated_shipping/wizard/assigned_picker.py'
--- sale_negotiated_shipping/wizard/assigned_picker.py 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/wizard/assigned_picker.py 2011-10-06 16:09:21 +0000
@@ -0,0 +1,66 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import pooler
24import wizard
25from tools.translate import _
26
27pick_form = """<?xml version="1.0"?>
28<form string="Change Assigned Picker">
29 <field name="picker" colspan="4"/>
30</form>
31"""
32
33pick_fields = {
34 'picker': {'string': 'Assigned Picker', 'type': 'many2one', 'relation': 'res.users'}
35}
36
37
38
39class wizard_assigned_picker(wizard.interface):
40
41
42 def do_action(self, cr, uid, data, context={}):
43 print data
44 pooler.get_pool(cr.dbname).get(data['model']).write(cr,uid,data['ids'],{'assigned_picker':data['form']['picker']})
45 return {}
46
47
48 states = {
49 'init': {
50 'actions': [],
51 'result': {'type': 'form', 'arch': pick_form, 'fields' : pick_fields, 'state' : [('end', 'Cancel'), ('update_delivery', 'Update Delivery Order') ]}
52 },
53 'update_delivery': {
54 'actions': [],
55 'result': {'type': 'action', 'action': do_action, 'state': 'end'}
56 },
57
58
59# 'init': {
60# 'actions': [],
61# 'result': {'type': 'action', 'action': do_action, 'state':'end'}
62# }
63 }
64wizard_assigned_picker('assigned_picker_order')
65
66# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
067
=== added file 'sale_negotiated_shipping/wizard/wizard_shipping_rate_calculation.py'
--- sale_negotiated_shipping/wizard/wizard_shipping_rate_calculation.py 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/wizard/wizard_shipping_rate_calculation.py 2011-10-06 16:09:21 +0000
@@ -0,0 +1,256 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22from osv import fields,osv
23import netsvc
24from tools.translate import _
25
26class shipping_rate_wizard(osv.osv_memory):
27 _name = "shipping.rate.wizard"
28 _description = "Calculates shipping charges"
29 _columns = {
30 'name': fields.one2many('shipping.rate.config','ups_shipping_wizard','Shipping Method'),
31 'shipping_cost':fields.float('Shipping Cost'),
32 'last_used':fields.char('Last Used',size="128"),
33 'account_id':fields.many2one('account.account', 'Account'),
34 'rate_select': fields.many2one('shipping.rate.config','Select'),
35 }
36 def _get_default_val(self,cr, uid, ids,context={}):
37 '''
38 Function to initialize shipping methods in shipping charge calculating wizard
39 '''
40 ret=[]
41 ship_conf_obj = self.pool.get('shipping.rate.config')
42 ship_conf_ids = ship_conf_obj.search(cr,uid,[])
43 account_id = False
44 for ship_conf in ship_conf_obj.browse(cr,uid,ship_conf_ids):
45 if ship_conf.account_id:
46 account_id = ship_conf.account_id.id
47 ret.append({'shipmethodname':ship_conf.shipmethodname,'use': 0,'real_id':ship_conf.id,'account_id':account_id})
48 return ret
49 _defaults = {'name':_get_default_val,
50 'last_used':'',
51
52 }
53 def update_sale_order(self, cr, uid, ids,context={}):
54 '''
55 Function to update sale order and invoice with new shipping cost and method
56 '''
57 datas = self.browse(cr, uid, ids[0], context=context)
58 if context.get('active_model',False) == 'sale.order':
59 sale_id = context.get('active_id',False)
60 sale_id and self.pool.get('sale.order').write(cr,uid,[sale_id],{'shipcharge':datas.shipping_cost,
61 'ship_method':datas.last_used,
62 'sale_account_id':datas.account_id.id,
63 'ship_method_id':datas.rate_select.id,})
64 self.pool.get('sale.order').button_dummy(cr, uid, [sale_id], context=context)
65 elif context.get('active_model',False) == 'account.invoice':
66 invoice_id = context.get('active_id',False)
67 if invoice_id:
68 if datas.account_id:
69 account_id = datas.account_id.id
70 else:
71 account_id = False
72 self.pool.get('account.invoice').write(cr,uid,[invoice_id],{
73 'shipcharge':datas.shipping_cost,
74 'ship_method':datas.last_used,
75 'ship_method_id':datas.rate_select.id,
76 'sale_account_id':datas.account_id.id,
77 })
78 self.pool.get('account.invoice').button_reset_taxes(cr, uid, [invoice_id], context=context)
79# For future development to add invoice line for shipping method
80# inv_line_ids = self.pool.get('account.invoice.line').search(cr,uid,[('invoice_id','=',invoice_id),('name','=','Shipping Charge')])
81# if inv_line_ids:
82# self.pool.get('account.invoice').write(cr,uid,invoice_id,{
83# 'shipcharge':datas.shipping_cost,
84# 'ship_method':datas.last_used,
85# })
86# self.pool.get('account.invoice.line').write(cr,uid,inv_line_ids,{'price_unit':datas.shipping_cost})
87# else:
88# if datas.account_id:
89# self.pool.get('account.invoice').write(cr,uid,invoice_id,{
90# 'shipcharge':datas.shipping_cost,
91# 'ship_method':datas.last_used,
92# 'invoice_line':[(0,0,{'name':'Shipping Charge',
93# 'quantity':1,
94# 'state':'article',
95# 'account_id':datas.account_id.id,
96# 'price_unit':datas.shipping_cost})]
97# })
98# else:
99# raise osv.except_osv(_('Warning !'), _('No account defined for this shipping rate configuration.'))
100
101
102
103 return {}
104 def find_cost(self, cr, uid, config_id, address, model_obj, type='sale_order', context={}):
105 '''
106 Function to calculate shipping cost
107 '''
108 cost=0
109 table_pool = self.pool.get('ups.shipping.rate')
110 config_pool = self.pool.get('shipping.rate.config')
111 logger = netsvc.Logger()
112 config_obj = config_pool.browse(cr,uid,config_id, context=context)
113 if config_obj.calc_method == 'country_weight':
114 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),])
115 if table_id:
116 table_obj = table_pool.browse(cr,uid,table_id[0],)
117 if table_obj.charge == 0.0 and table_obj.over_cost:
118 cost = model_obj.total_weight_net*table_obj.over_cost
119 else:
120 cost = table_obj.charge
121
122 else:
123 table_ids = table_pool.search(cr,uid,[('card_id','=',config_obj.rate_card_id.id),('country_id','=',address.country_id.id),('over_cost','>',0)])
124 if table_ids:
125 table_objs = table_pool.browse(cr,uid,table_ids)
126 table_obj = table_objs[0]
127 for table in table_objs:
128 if table_obj.from_weight < table.from_weight:
129 table_obj = table
130 weight = model_obj.total_weight_net
131 if table_obj.charge > 0:
132 cost = table_obj.charge
133 weight -= table_obj.from_weight
134 if weight>0:
135 cost += weight*table_obj.over_cost
136 else:
137 cost = weight*table_obj.over_cost
138 else:
139 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)))
140
141 elif config_obj.calc_method == 'state_zone_weight':
142 zone_pool = self.pool.get('ups.zone.map')
143 zone_id = zone_pool.search(cr,uid,[('rate_config_id','=',config_obj.id),('state_id','=',address.state_id.id),])
144 if zone_id:
145 zone = zone_pool.read(cr,uid,zone_id,['zone'])[0]['zone']
146 table_id = table_pool.search(cr,uid,[('card_id','=',config_obj.rate_card_id.id),('zone','=',zone),])
147 if table_id:
148 table_obj = table_pool.browse(cr,uid,table_id)[0]
149 weight = model_obj.total_weight_net
150 if table_obj.charge > 0:
151 cost = table_obj.charge
152 weight -= table_obj.to_weight
153 if weight>0:
154 cost += weight*table_obj.over_cost
155 else:
156 cost = weight*table_obj.over_cost
157 else:
158 logger.notifyChannel(_("Calculate Shipping"), netsvc.LOG_WARNING, _("Unable to find rate table with Shipping Table = %s and Zone = %s."%(config_obj.shipmethodname,zone)))
159 else:
160 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)))
161 elif config_obj.calc_method == 'manual':
162 cost = 0.0
163 return cost
164
165 def onchange_select_ups(self, cr, uid, ids, name, last_used, context={}):
166 '''
167 Function to update shipping charge when clicking on different types of shipping method
168 '''
169 new_list = []
170 new_last_used = last_used
171 cost = 0
172 account_id = False
173 ret = {}
174 ship_conf_obj = self.pool.get('shipping.rate.config')
175 ship_conf_ids = ship_conf_obj.search(cr,uid,[])
176 if context.get('active_model',False) == 'sale.order' and context.get('active_id',False):
177 if name and len(name) == len(ship_conf_ids):
178 new_last_used = ''
179 value = 0
180 for line in name:
181 if line[2]['shipmethodname'] == last_used:
182 line[2]['use'] = 0
183 line[2]['shipmethodname'] and new_list.append(line[2])
184 if line[2]['use']:
185 new_last_used = line[2]['shipmethodname']
186 account_id = line[2]['account_id']
187 sale_id = context.get('active_id',False)
188 sale_order = self.pool.get('sale.order').browse(cr,uid,sale_id,context=context)
189 cr.execute('select type,id from res_partner_address where partner_id IN %s',(tuple([sale_order.partner_id.id]),))
190 res = cr.fetchall()
191 adr = dict(res)
192 if adr:
193 if adr.get('delivery',False):
194 adr_id = adr['delivery']
195 elif adr.get('default',False):
196 adr_id = adr['default']
197 else:
198 adr_id = adr.values()[0]
199 address = self.pool.get('res.partner.address').browse(cr, uid,adr_id,context=context)
200 config_id = line[2]['real_id']
201 cost=self.find_cost(cr, uid, config_id, address,sale_order, type='sale_order', context=context)
202 ret = {'value':{'shipping_cost':cost,'last_used':new_last_used,'name':new_list,'account_id':account_id}}
203 elif len(name) > len(ship_conf_ids):
204 for ship_conf in ship_conf_obj.browse(cr,uid,ship_conf_ids):
205 new_list.append({'shipmethodname':ship_conf.shipmethodname,'use': 0})
206 ret = {'value':{'last_used':new_last_used,'name':new_list}}
207 elif context.get('active_model',False) == 'account.invoice' and context.get('active_id',False):
208 if name and len(name) == len(ship_conf_ids):
209 new_last_used = ''
210 value = 0
211 for line in name:
212 if line[2]['shipmethodname'] == last_used:
213 line[2]['use'] = 0
214 line[2]['shipmethodname'] and new_list.append(line[2])
215 if line[2]['use']:
216 new_last_used = line[2]['shipmethodname']
217 account_id = line[2]['account_id']
218 invoice_id = context.get('active_id',False)
219 invoice = self.pool.get('account.invoice').browse(cr,uid,invoice_id,context=context)
220 cr.execute('select type,id from res_partner_address where partner_id IN %s',(tuple([invoice.partner_id.id]),))
221 res = cr.fetchall()
222 adr = dict(res)
223 if adr:
224 if adr.get('delivery',False):
225 adr_id = adr['delivery']
226 elif adr.get('default',False):
227 adr_id = adr['default']
228 else:
229 adr_id = adr.values()[0]
230 address = self.pool.get('res.partner.address').browse(cr, uid,adr_id,context=context)
231 config_id = line[2]['real_id']
232 cost=self.find_cost(cr, uid, config_id, address,invoice, type='invoice', context=context)
233 ret = {'value':{'shipping_cost':cost,'last_used':new_last_used,'name':new_list,'account_id':account_id,}}
234 elif len(name) > len(ship_conf_ids):
235 for ship_conf in ship_conf_obj.browse(cr,uid,ship_conf_ids):
236 new_list.append({'shipmethodname':ship_conf.shipmethodname,'use': 0})
237 ret = {'value':{'last_used':new_last_used,'name':new_list}}
238 return ret
239
240 def onchange_select(self, cr, uid, ids, name, last_used, rate_select, context={}):
241 new_list = []
242 ship_conf_obj = self.pool.get('shipping.rate.config')
243 ship_conf_ids = ship_conf_obj.search(cr,uid,[])
244 account_id = False
245 for line in ship_conf_obj.browse(cr,uid,ship_conf_ids):
246 use = 0
247 if line.id == rate_select:
248 use=1
249 new_list.append((0,0,{'use':use,'real_id':line.id,'account_id':line.account_id.id,'shipmethodname':line.shipmethodname}))
250 ret = self.onchange_select_ups(cr, uid, ids, new_list, last_used, context=context)
251 return ret
252
253shipping_rate_wizard()
254
255
256# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0257
=== added file 'sale_negotiated_shipping/wizard/wizard_shipping_rate_view.xml'
--- sale_negotiated_shipping/wizard/wizard_shipping_rate_view.xml 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/wizard/wizard_shipping_rate_view.xml 2011-10-06 16:09:21 +0000
@@ -0,0 +1,36 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <!-- Shipping rate wizard -->
5 <record id="view_for_shipping_rate_wizard" model="ir.ui.view">
6 <field name="name">action_for_shipping_rate_wizard</field>
7 <field name="model">shipping.rate.wizard</field>
8 <field name="type">form</field>
9 <field name="arch" type="xml">
10 <form string="Shipping Method" >
11 <group colspan="1" col="2">
12 <newline/>
13 <field name="last_used" invisible="1"/>
14 <field name="account_id" invisible="1"/>
15 <newline/>
16 <field name="rate_select" string="Shipping Method" on_change="onchange_select(name,last_used,rate_select,context)" widget="selection" colspan="1"/>
17 <field name="shipping_cost" colspan="1"/>
18 <newline/>
19 <button special="cancel" string="Cancel" icon="gtk-close"/>
20 <button name="update_sale_order" string="OK" type="object" icon="gtk-ok" />
21 </group>
22 </form>
23 </field>
24 </record>
25
26
27 <record id="action_view_for_shipping_rate_wizard" model="ir.actions.act_window">
28 <field name="name">action_for_shipping_rate_wizard</field>
29 <field name="type">ir.actions.act_window</field>
30 <field name="res_model">shipping.rate.wizard</field>
31 <field name="view_type">form</field>
32 <field name="view_mode">form</field>
33 <field name="target">new</field>
34 </record>
35 </data>
36</openerp>
0\ No newline at end of file37\ No newline at end of file
138
=== added file 'sale_negotiated_shipping/wizard_view.xml'
--- sale_negotiated_shipping/wizard_view.xml 1970-01-01 00:00:00 +0000
+++ sale_negotiated_shipping/wizard_view.xml 2011-10-06 16:09:21 +0000
@@ -0,0 +1,10 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <wizard id="assigned_picker_order_id" model="stock.picking"
5 multi="True" name="assigned_picker_order" string="Assigned Picker"/>
6
7 <wizard id="assigned_picker_move_id" model="stock.move"
8 multi="True" name="assigned_picker_order" string="Assigned Picker"/>
9 </data>
10</openerp>

Subscribers

People subscribed via source and target branches

to all changes: