Hi all,
I'm trying to show some fields on invoice report (pdf) when checkbox is ticked on sale order form. On sales order report I got to show it like this https://ibb.co/rcd7fFD
show_reference_1 is defined here https://ibb.co/VBb8mt3
And it work great on sales order but I can't get it to work on invoice report -> if checkbox is ticked on sales order form if condition should be true and it should show.
I tried to create related fields as described here
https://www.odoo.com/forum/help-1/odoo-10-show-field-of-model-sale-order-in-form-view-of-account-invoice-113470
but got ImportError: cannot import name 'account_invoice' from partially initialized module...
This is inside py file https://ibb.co/QfSzwcg
Maybe this error is due missing import inside __init__.py ? This is what I got inside it https://ibb.co/mt3FRgL
Anyway - does somebody know a way to trigger if condition on invoice report related to sale order form tickbox? Thank you.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
f you are using Odoo 13.0 and above, the account.invoice is replaced with account.move so you need to inheritfrom account.move.
class AccountMove(models.Model)
_inherit = 'account.move'
Yeah, I tried with account.move - no errors. But it doesn't show fields on invoice when checkbox are ticked. To test it I tried to show them on form and indeed they are not ticked but on sale order form they are ticked.
Here is code used for it https://ibb.co/pWKdGv4
Fields are inherited - they show up on account move form but their values (weather its ticked) are not. Do you have any idea how to inherit those values from sale order on account move?
You added the sale order id field but you have to select the sale order in the form, Or you can pass it once you create invoice from sale order.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Aug 24
|
98 | ||
|
1
Feb 22
|
3362 | ||
|
2
May 19
|
2406 | ||
|
3
Aug 18
|
3893 | ||
|
8
Feb 16
|
9883 |
which ODOO Version are you using?
v15 - account.move has to be inherited. The problem is when this fields are inherited they aren't ticked - maybe I'm inheriting them wrong. Here is how it's done at the moment https://ibb.co/pWKdGv4
You need to add sale order id to the form and select the sale order linked to the invoice manually in the form and then the related boolean field will have the values from sale order. You can override the method which create invoice from sale order to pass the sale order id to invoice sale order id and this will avoid you to select the sale order manually in the invoice.
@Waleed Mohsen I'm not sure I get it - how to add sale order id to the form to select the sale order linked to the invoice? I'd really appreciate if you can explain.
You have added sale_order_id many2One field to account.move but the field will be empty in invoice so you need to add it to invoice form and then select the SO linked to the invoice. otherwise the sale_order_id will be false and the your boolean field will not have any value.
Great. You got it.
Sorry - didn't realised that it just saved order ID when I selected it but it is not selected by default. Can you please tell me how to pass sale order id to this field so correct order in it is selected by default?
You need to override method _prepare_invoice in sale.order model to pass sale order id to account.move sale_order_id field.
def _prepare_invoice(self):
invoice_vals = super(SaleOrder, self)._prepare_invoice()
invoice_vals['sale_order_id'] = self.id
return invoice_vals
So when you create invoice from sale order the sale_order_id will be set automatically. for already created invoice, you have to set it manually or by using export/import.
That's it - thank you 🙏 😊