Odoo Help

0

0
4 Answers
0
Avatar

Pawan Kumar Sharma

--Pawan Kumar Sharma--
SunArc Technologies
8488
| 6 2 7
Bikaner, 印度
--Pawan Kumar Sharma--


Pawan Kumar Sharma
2018/10/9 上午12:55

Hello @Russ,

in account.invoice direct sale_order_id field not available. Here is only sale order name('origin') available. So, You can solve this problem by following field. after that you can make any field related with custom so_reference field.

@api.model
def get_sale_order_reference(self):
for rec in self:
res = rec.env['sale.order'].search([('name', '=', rec.origin)])
rec.so_reference = res

so_reference = fields.Many2one('sale.order', compute='get_sale_order_reference')

I hope it will work for you.

0
IT Support
2019/6/17 下午5:15

Hello Mitul,

What's the purpose of the first override method _create_invoice()?  It seems like the sale order custom field already flows through the invoice header with just the overriding of _prepare_invoice().

Thanks,

Joseph

0
Avatar

subbarao

--subbarao--

1269
| 5 2 8
Chennai, 印度
--subbarao--


subbarao
2018/10/9 上午3:09

Hello Russ Schneider,

By default account.invoice does't have sale_order_id field.

Invoice line have sale_order_line relation

from sale_order_line you can get sale_order_id (sale_order_line.order_id)

0
Avatar

Mitul Shingala

--Mitul Shingala--
--Mitul Shingala--

Odoo Developer

Mitul Shingala
2018/10/9 上午3:14

Hello,

 you can override the method of sale order and sale_advance_payment_inv object. when you create new invoice at that time you need to pass the value of your custom field.

You need to override this method.


class SaleAdvancePaymentInv(models.TransientModel):
   _inherit = "sale.advance.payment.inv"
@api.multi def _create_invoice(self, order, so_line, amount):
invoice = super(SaleAdvancePaymentInv, self)._create_invoice(order, so_line, amount):
      invoice.write({'project_name': order.project_name})
return invoice

and second method of sale order class

class sale_order(models.Model)
   _inherit = 'sale.order'
   
@api.multi
    def _prepare_invoice(self):
      res = super(sale_order, self)._prepare_invoice()
      res.update({'project_name': self.project_name})
      return res
Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now