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

Why is my tax not filled in when using an automated action?

By
Yenthe
on 5/4/15, 3:00 AM 483 views

Hi guys,

I've extended the ability to automatically generate invoices from contracts. In the contracts page I've added the ability to add cars to contracts and on this car you can set a tax. See an example image here.

The cars field is a many2one to fleet.vehicle and inside this many2one I have a many2many relation to account.tax.
Python code:

_columns = {
   'car_id': fields.many2one('fleet.vehicle', 'Cars'), 
   'car_line_tax_id': fields.many2many('account.tax', 'account_car_line_tax', 'car_line_id', 'tax_id', string='BTW')

I now add a car to the car_id many2one and fill in a tax (for example: VAT-OUT-21-SERVICES). I then run the automatic planner which triggers a Python method that generates concept invoices from the contracts:

def _prepare_invoice_lines(self, cr, uid, contract, fiscal_position_id, context=None):
    //Lots of irrelevant code.
    //Loop over all cars that are added to the car_id list.
    for line in contract.recurring_invoice_car_line_ids: 
        //Add every car to the invoices_lines
        invoice_lines.append((0, 0, { 
            //Fill up the fields
            'quantity': line.car_number_of_units or 0.0,
            'price_unit': line.car_rent_price or 0.0, 
            //This line isn't working well. I know the filled in tax is in car_line_tax_id but it doesn't get filled in on the invoice.
'invoice_line_tax_id': line.car_line_tax_id,

So everything works fine except 'invoice_line_tax_id': line.car_line_tax_id. For some reason the tax doesn't get filled in in account.invoice.form on the field invoice_lines_tax_id. You can see an example here from both screens.

Why is this? Did I do something wrong or?

Thanks,
Yenthe



1

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 5/4/15, 6:04 AM

Try adding in such a way:

'invoice_line_tax_id': [(6, 0, [x.id for x in line.car_line_tax_id)], 

Works perfect! So why do you have to loop over them? Why can't I simply call the id? Because it can contain multiple values? Accepted & upvoted, thanks Zbik!

Yenthe
on 5/4/15, 7:10 AM

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: 5/4/15, 3:00 AM
Seen: 483 times
Last updated: 5/4/15, 7:09 AM