Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to pre-fill the tax in sale order lines before adding a product?

By
J Miller
on 7/3/15, 3:57 AM 545 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!


1

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 7/3/15, 4:21 AM

Miller,

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

Thanks.

0
J Miller
On 7/3/15, 5:27 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/3/15, 3:57 AM
Seen: 545 times
Last updated: 7/3/15, 5:39 AM