diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 3d909c1085e..026f10647ec 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -207,6 +207,7 @@ class purchase_order(osv.osv):
'product_id': fields.related('order_line','product_id', type='many2one', relation='product.product', string='Product'),
'create_uid': fields.many2one('res.users', 'Responsible'),
'company_id': fields.many2one('res.company','Company',required=True,select=1),
+ 'tax_id': fields.many2one('account.tax', 'Tax'),
}
_defaults = {
'date_order': fields.date.context_today,
@@ -295,7 +296,7 @@ class purchase_order(osv.osv):
return True
def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None):
- """Collects require data from purchase order line that is used to create invoice line
+ """Collects require data from purchase order line that is used to create invoice line
for that purchase order line
:param account_id: Expense account of the product of PO line if any.
:param browse_record order_line: Purchase order line browse record
@@ -379,7 +380,7 @@ class purchase_order(osv.osv):
'address_invoice_id': order.partner_address_id.id,
'address_contact_id': order.partner_address_id.id,
'journal_id': len(journal_ids) and journal_ids[0] or False,
- 'invoice_line': [(6, 0, inv_lines)],
+ 'invoice_line': [(6, 0, inv_lines)],
'origin': order.name,
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
'payment_term': order.partner_id.property_payment_term and order.partner_id.property_payment_term.id or False,
@@ -420,7 +421,7 @@ class purchase_order(osv.osv):
if inv:
wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr)
self.write(cr,uid,ids,{'state':'cancel'})
-
+
for (id, name) in self.name_get(cr, uid, ids):
wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_cancel', cr)
message = _("Purchase order '%s' is cancelled.") % name
@@ -439,7 +440,7 @@ class purchase_order(osv.osv):
'company_id': order.company_id.id,
'move_lines' : [],
}
-
+
def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None):
return {
'name': order.name + ': ' + (order_line.name or ''),
@@ -480,7 +481,7 @@ class purchase_order(osv.osv):
will be added. A new picking will be created if omitted.
:return: list of IDs of pickings used/created for the given order lines (usually just one)
"""
- if not picking_id:
+ if not picking_id:
picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context))
todo_moves = []
stock_move = self.pool.get('stock.move')
@@ -732,7 +733,7 @@ class purchase_order_line(osv.osv):
"""
if context is None:
context = {}
-
+
res = {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or '', 'product_uom' : uom_id or False}}
if not product_id:
return res
@@ -756,7 +757,7 @@ class purchase_order_line(osv.osv):
context_partner = {'lang': lang, 'partner_id': partner_id}
product = product_product.browse(cr, uid, product_id, context=context_partner)
res['value'].update({'name': product.name, 'notes': notes or product.description_purchase})
-
+
# - set a domain on product_uom
res['domain'] = {'product_uom': [('category_id','=',product.uom_id.category_id.id)]}
@@ -764,7 +765,7 @@ class purchase_order_line(osv.osv):
product_uom_po_id = product.uom_po_id.id
if not uom_id:
uom_id = product_uom_po_id
-
+
if product.uom_id.category_id.id != product_uom.browse(cr, uid, uom_id, context=context).category_id.id:
res['warning'] = {'title': _('Warning'), 'message': _('Selected UOM does not belong to the same category as the product UOM')}
uom_id = product_uom_po_id
@@ -794,7 +795,7 @@ class purchase_order_line(osv.osv):
# - determine price_unit and taxes_id
price = product_pricelist.price_get(cr, uid, [pricelist_id],
product.id, qty or 1.0, partner_id, {'uom': uom_id, 'date': date_order})[pricelist_id]
-
+
taxes = account_tax.browse(cr, uid, map(lambda x: x.id, product.supplier_taxes_id))
fpos = fiscal_position_id and account_fiscal_position.browse(cr, uid, fiscal_position_id, context=context) or False
taxes_ids = account_fiscal_position.map_tax(cr, uid, fpos, taxes)
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index e6260c1c13f..6388894cd0b 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -39,7 +39,7 @@
+ parent="purchase.menu_product_in_config_purchase" sequence="20" groups="base.group_sale_uom_per_product"/>
-
+
-
-
+
+
+
@@ -304,7 +305,7 @@
-
+
purchase.order.treepurchase.order
@@ -361,13 +362,13 @@
-
+
-
+
@@ -403,7 +404,7 @@
-
+
@@ -424,7 +425,7 @@
-
+
diff --git a/addons/purchase/res_config.py b/addons/purchase/res_config.py
index 52f726e8873..937f1920c1a 100644
--- a/addons/purchase/res_config.py
+++ b/addons/purchase/res_config.py
@@ -24,15 +24,16 @@ import pooler
from tools.translate import _
class purchase_configuration(osv.osv_memory):
+ _name = 'purchase.configuration'
_inherit = 'res.config.settings'
_columns = {
- 'default_method' : fields.selection(
+ 'default_invoice_method' : fields.selection(
[('manual', 'Based on Purchase Order Lines'),
('picking', 'Based on Receptions'),
('order', 'Pre-Generate Draft Invoices based on Purchase Orders'),
- ], 'Invoicing Control Method', required=True , help="You can set Invoicing Control Method."),
- 'module_purchase_analytic_plans': fields.boolean('Purchase Analytic Plan',
+ ], 'Invoicing Control Method', required=True, default_model='purchase.order' , help="You can set Invoicing Control Method."),
+ 'module_purchase_analytic_plans': fields.boolean('Purchase analytic plan',
help ="""
Allows the user to maintain several analysis plans. These let you split
a line on a supplier purchase order into several accounts and analytic plans.
@@ -42,14 +43,14 @@ class purchase_configuration(osv.osv_memory):
help="""To trigger warnings in OpenERP objects.
Warning messages can be displayed for objects like sale order, purchase order, picking and invoice. The message is triggered by the form's onchange event.
It installs the warning module."""),
- 'module_product_manufacturer': fields.boolean("Define a manufacturer on products",
- help="""TYou can now define the following for a product:
+ 'module_product_manufacturer': fields.boolean("Define a manufacturer of products",
+ help="""This allows you to define the following for a product:
* Manufacturer
* Manufacturer Product Name
* Manufacturer Product Code
* Product Attributes.
It installs the product_manufacturer module."""),
- 'module_purchase_double_validation': fields.boolean("Configure Limit amount",
+ 'module_purchase_double_validation': fields.boolean("Configure limit amount",
help="""This allows you double-validation for purchases exceeding minimum amount.
It installs the purchase_double_validation module."""),
'module_purchase_requisition' : fields.boolean("Track the best price with Purchase Requisition",
@@ -69,15 +70,27 @@ class purchase_configuration(osv.osv_memory):
'group_purchase_taxes_on_order_line':fields.boolean("On order line", group='base.group_user', implied_group='base.group_purchase_taxes_on_order_line'),
}
+ def default_get(self, cr, uid, fields, context=None):
+ data_obj = self.pool.get('ir.model.data')
+ res = super(purchase_configuration, self).default_get(cr, uid, fields, context)
+ if res.get('group_purchase_taxes_global_on_order'):
+ res.update({'tax_policy': 'global_on_order'})
+ elif res.get('group_purchase_taxes_on_order_line'):
+ res.update({'tax_policy': 'on_order_line'})
+ else:
+ res.update({'tax_policy': 'no_tax'})
+ return res
+
+
_defaults = {
- 'default_method': lambda s,c,u,ctx: s.pool.get('purchase.order').default_get(c,u,['invoice_method'],context=ctx)['invoice_method'],
+ 'default_invoice_method': lambda s,c,u,ctx: s.pool.get('purchase.order').default_get(c,u,['invoice_method'],context=ctx)['invoice_method'],
'tax_policy': 'global_on_order',
}
def _check_default_tax(self, cr, uid, context=None):
ir_values_obj = self.pool.get('ir.values')
for tax in ir_values_obj.get(cr, uid, 'default', False, ['product.product']):
- if tax[1] == 'taxes_id':
+ if tax[1] == 'supplier_taxes_id':
return tax[2]
return False
@@ -86,13 +99,11 @@ class purchase_configuration(osv.osv_memory):
taxes = self._check_default_tax(cr, uid, context=context)
if taxes:
ir_values_obj.set(cr, uid, 'default', False, 'tax_id', ['purchase.order'], taxes[0])
- ir_values_obj.set(cr, uid, 'default', False, 'tax_id', ['purchase.order.line'], taxes)
- ir_values_obj.set(cr, uid, 'default', False, 'taxes_id', ['product.product'], taxes)
+ ir_values_obj.set(cr, uid, 'default', False, 'taxes_id', ['purchase.order.line'], taxes)
+ ir_values_obj.set(cr, uid, 'default', False, 'supplier_taxes_id', ['product.product'], taxes)
def onchange_tax_policy(self, cr, uid, ids, tax_policy, context=None):
res = {'value': {}}
- if ids:
- self.set_tax_policy(cr, uid, ids, context=context)
if tax_policy == 'global_on_order':
res['value'].update({'group_purchase_taxes_global_on_order': True})
res['value'].update({'group_purchase_taxes_on_order_line': False})
diff --git a/addons/purchase/res_config_view.xml b/addons/purchase/res_config_view.xml
index 5a3274017a4..2b4a5f88398 100644
--- a/addons/purchase/res_config_view.xml
+++ b/addons/purchase/res_config_view.xml
@@ -3,13 +3,13 @@
Purchase Application
- res.config.settings
+ purchase.configurationform