Skip to Content
Menu
This question has been flagged
2 Replies
5230 Views

As a service company we do not use products and therefore we cannot predefine the tax in order lines which is usually defined by the product. I wrote a simple extension to set the tax on sale order line on creation:

class SaleOrderLine(osv.osv):
_inherit = 'sale.order.line'


def create(self, cr, uid, values, context=None):

        tax = self.pool.get('account.tax').browse(cr, uid, 12, context=context)
        values['tax_id'] = [[6, 0, [tax.id]]]

        return super(SaleOrderLine, self).create(cr, uid, values, context=context)



My questions are:

1.) How can I obtain the default sales tax from account configuration within the SaleOrderLine extension?

2.) At the moment the tax will be set after saving the sale order. Is there a way to pre-fill the tax field on creatrion of an order line in the frontend (Link: Add Entry)? I presume this must be done with JavaScript but I do not know how to obtain the default sales tax there and how to add a default value to the tax field.


Thanks for your help!


Avatar
Discard
Best Answer

Miller,

You just use the logic of yours into the default_get() of sale.order.line rather than create().

Thanks.

Avatar
Discard
Author Best Answer

Great! that answers my second question.

But how can I access the default sales tax from account configurations?

Got the answer myself:

ir_values = self.pool.get('ir.values')
taxes_id = ir_values.get_default(cr, uid, 'product.product', 'taxes_id', company_id=company_id)

see https://www.odoo.com/fr_FR/forum/help-1/question/get-default-tax-using-code-14728
Avatar
Discard
Related Posts Replies Views Activity
0
Sep 24
122
3
Aug 24
528
0
Feb 24
264
0
Feb 24
157
1
Jan 24
1326