Put Payment Term in the sale order. When we change the partner, it sets the right payment term according to what have been defined in the res.partner.
When creating invoices from sale order or from picking, uses the payment term of the sale order instead of the one of the partner. bzr revid: hmo@tinyerp.com-20080825115456-hwftk6ehj69392bp
This commit is contained in:
parent
4b4acd020d
commit
78f828620b
|
@ -239,6 +239,7 @@ class sale_order(osv.osv):
|
|||
'amount_tax': fields.function(_amount_tax, method=True, string='Taxes'),
|
||||
'amount_total': fields.function(_amount_total, method=True, string='Total'),
|
||||
'invoice_quantity': fields.selection([('order','Ordered Quantities'),('procurement','Shipped Quantities')], 'Invoice on', help="The sale order will automatically create the invoice proposition (draft invoice). Ordered and delivered quantities may not be the same. You have to choose if you invoice based on ordered or shipped quantities. If the product is a service, shipped quantities means hours spent on the associated tasks."),
|
||||
'payment_term' : fields.many2one('account.payment.term', 'Payment Term'),
|
||||
}
|
||||
_defaults = {
|
||||
'picking_policy': lambda *a: 'direct',
|
||||
|
@ -281,10 +282,11 @@ class sale_order(osv.osv):
|
|||
|
||||
def onchange_partner_id(self, cr, uid, ids, part):
|
||||
if not part:
|
||||
return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False}}
|
||||
return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False, 'payment_term' : False}}
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery','invoice','contact'])
|
||||
pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist.id
|
||||
return {'value':{'partner_invoice_id': addr['invoice'], 'partner_order_id':addr['contact'], 'partner_shipping_id':addr['delivery'], 'pricelist_id': pricelist}}
|
||||
payment_term = self.pool.get('res.partner').browse(cr, uid, part).property_payment_term.id
|
||||
return {'value':{'partner_invoice_id': addr['invoice'], 'partner_order_id':addr['contact'], 'partner_shipping_id':addr['delivery'], 'pricelist_id': pricelist, 'payment_term' : payment_term}}
|
||||
|
||||
def button_dummy(self, cr, uid, ids, context={}):
|
||||
return True
|
||||
|
@ -298,8 +300,8 @@ class sale_order(osv.osv):
|
|||
|
||||
def _make_invoice(self, cr, uid, order, lines):
|
||||
a = order.partner_id.property_account_receivable.id
|
||||
if order.partner_id and order.partner_id.property_payment_term.id:
|
||||
pay_term = order.partner_id.property_payment_term.id
|
||||
if order.payment_term:
|
||||
pay_term = order.payment_term.id
|
||||
else:
|
||||
pay_term = False
|
||||
for preinv in order.invoice_ids:
|
||||
|
|
|
@ -167,6 +167,7 @@
|
|||
<field groups="base.group_extended" name="origin"/>
|
||||
<field groups="base.group_extended" name="invoice_quantity" attrs="{'readonly':[('order_policy','=','picking')]}"/>
|
||||
<field name="client_order_ref"/>
|
||||
<field name="payment_term"/>
|
||||
<separator colspan="4" string="Notes"/>
|
||||
<field colspan="4" name="note" nolabel="1"/>
|
||||
</page>
|
||||
|
|
|
@ -606,15 +606,14 @@ class stock_picking(osv.osv):
|
|||
for picking in self.browse(cursor, user, ids, context=context):
|
||||
if picking.invoice_state != '2binvoiced':
|
||||
continue
|
||||
|
||||
payment_term_id = False
|
||||
partner = picking.address_id.partner_id
|
||||
if type in ('out_invoice', 'out_refund'):
|
||||
account_id = partner.property_account_receivable.id
|
||||
payment_term_id= picking.sale_id.payment_term.id
|
||||
else:
|
||||
account_id = partner.property_account_payable.id
|
||||
payment_term_id = False
|
||||
if partner.property_payment_term:
|
||||
payment_term_id = partner.property_payment_term.id
|
||||
# payment_term_id = picking.purchase_id.payment_term.id
|
||||
|
||||
address_contact_id, address_invoice_id = \
|
||||
self._get_address_invoice(cursor, user, picking).values()
|
||||
|
|
Loading…
Reference in New Issue