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"/> - + - - + + +