[FIX] purchase: apply appropriate fiscal position when PO created automatically
When a PO is created automatically from a procurement, the fiscal position is
not chosen correctly. We need to choose the fiscal position in the same way if
the PO is created manually or automatically.
Follows commit 1062905acb
Fixes #3863
opw-643916
This commit is contained in:
parent
00afd776fd
commit
24556120e7
|
@ -1336,6 +1336,7 @@ class procurement_order(osv.osv):
|
||||||
pricelist_obj = self.pool.get('product.pricelist')
|
pricelist_obj = self.pool.get('product.pricelist')
|
||||||
prod_obj = self.pool.get('product.product')
|
prod_obj = self.pool.get('product.product')
|
||||||
acc_pos_obj = self.pool.get('account.fiscal.position')
|
acc_pos_obj = self.pool.get('account.fiscal.position')
|
||||||
|
po_obj = self.pool.get('purchase.order')
|
||||||
|
|
||||||
seller_qty = procurement.product_id.seller_qty if procurement.location_id.usage != 'customer' else 0.0
|
seller_qty = procurement.product_id.seller_qty if procurement.location_id.usage != 'customer' else 0.0
|
||||||
pricelist_id = partner.property_product_pricelist_purchase.id
|
pricelist_id = partner.property_product_pricelist_purchase.id
|
||||||
|
@ -1350,7 +1351,12 @@ class procurement_order(osv.osv):
|
||||||
new_context.update({'lang': partner.lang, 'partner_id': partner.id})
|
new_context.update({'lang': partner.lang, 'partner_id': partner.id})
|
||||||
product = prod_obj.browse(cr, uid, procurement.product_id.id, context=new_context)
|
product = prod_obj.browse(cr, uid, procurement.product_id.id, context=new_context)
|
||||||
taxes_ids = procurement.product_id.supplier_taxes_id
|
taxes_ids = procurement.product_id.supplier_taxes_id
|
||||||
taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids)
|
# It is necessary to have the appropriate fiscal position to get the right tax mapping
|
||||||
|
fiscal_position = False
|
||||||
|
fiscal_position_id = po_obj.onchange_partner_id(cr, uid, None, partner.id, context=context)['value']['fiscal_position']
|
||||||
|
if fiscal_position_id:
|
||||||
|
fiscal_position = acc_pos_obj.browse(cr, uid, fiscal_position_id, context=context)
|
||||||
|
taxes = acc_pos_obj.map_tax(cr, uid, fiscal_position, taxes_ids)
|
||||||
name = product.display_name
|
name = product.display_name
|
||||||
if product.description_purchase:
|
if product.description_purchase:
|
||||||
name += '\n' + product.description_purchase
|
name += '\n' + product.description_purchase
|
||||||
|
@ -1462,7 +1468,7 @@ class procurement_order(osv.osv):
|
||||||
'currency_id': partner.property_product_pricelist_purchase and partner.property_product_pricelist_purchase.currency_id.id or procurement.company_id.currency_id.id,
|
'currency_id': partner.property_product_pricelist_purchase and partner.property_product_pricelist_purchase.currency_id.id or procurement.company_id.currency_id.id,
|
||||||
'date_order': purchase_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
'date_order': purchase_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||||
'company_id': procurement.company_id.id,
|
'company_id': procurement.company_id.id,
|
||||||
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False,
|
'fiscal_position': po_obj.onchange_partner_id(cr, uid, None, partner.id, context=context)['value']['fiscal_position'],
|
||||||
'payment_term_id': partner.property_supplier_payment_term.id or False,
|
'payment_term_id': partner.property_supplier_payment_term.id or False,
|
||||||
'dest_address_id': procurement.partner_dest_id.id,
|
'dest_address_id': procurement.partner_dest_id.id,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue