Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue of using null variable #30282

Open
wants to merge 1 commit into
base: 12.0
from

Conversation

Projects
None yet
4 participants
@MohsenWaleed
Copy link
Contributor

MohsenWaleed commented Jan 16, 2019

Description of the issue/feature this PR addresses:
account analytic defaults app prevent set default analytic account for invoice line.

Current behavior before PR:
The analytic account default value not set to a invoice line.

Desired behavior after PR is merged:
The analytic account default value should be set to a invoice line.

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@mart-e

This comment has been minimized.

Copy link
Contributor

mart-e commented Jan 21, 2019

cc @jorenvo @qdp-odoo as you have worked last on that module.

Seeing what is done in the prepare method on the sale_order, I think it makes sense to apply the same in the onchange but maybe the usecase is different. Opinion?

def _prepare_invoice_line(self, qty):
res = super(SaleOrderLine, self)._prepare_invoice_line(qty)
default_analytic_account = self.env['account.analytic.default'].account_get(self.product_id.id, self.order_id.partner_id.id, self.order_id.user_id.id, fields.Date.today())
if default_analytic_account:
res.update({'account_analytic_id': default_analytic_account.analytic_id.id})
res.update({'analytic_tag_ids' : [(6, 0, default_analytic_account.analytic_tag_ids.ids)]})
return res

vs

def _onchange_product_id(self):
res = super(AccountInvoiceLine, self)._onchange_product_id()
rec = self.env['account.analytic.default'].account_get(self.product_id.id, self.invoice_id.commercial_partner_id.id, self.env.uid,
fields.Date.today(), company_id=self.company_id.id)
self.account_analytic_id = rec.analytic_id.id
self.analytic_tag_ids = rec.analytic_tag_ids.ids
return res

@mart-e

This comment has been minimized.

Copy link
Contributor

mart-e commented Jan 21, 2019

@MohsenWaleed also, could you sign the CLA please so we can integrate your patch?

@MohsenWaleed

This comment has been minimized.

Copy link
Contributor Author

MohsenWaleed commented Jan 22, 2019

@MohsenWaleed also, could you sign the CLA please so we can integrate your patch?

Thanks @mart-e. I have signed it.

@jorenvo

This comment has been minimized.

Copy link
Contributor

jorenvo commented Jan 22, 2019

@mart-e to me this PR makes sense. I don't see a reason to clear analytic fields when there is no analytic default.

@mart-e mart-e force-pushed the MohsenWaleed:patch-1 branch to 39d79e4 Jan 23, 2019

@mart-e mart-e referenced this pull request Jan 23, 2019

Closed

Create MohsenWaleed.md #30441

@MohsenWaleed

This comment has been minimized.

Copy link
Contributor Author

MohsenWaleed commented Mar 25, 2019

@mart-e I already signed CLA but the patch is not integrated

[FIX] account_analytic_default: apply same logic as in _prepare_invoi…
…ce_line

It was not possible to manually set a default analytic account as it was
overriden by the onchange, even if no account was returned by account_get

Apply the same logic as in _prepare_invoice_line on sale.order.line

@mart-e mart-e force-pushed the MohsenWaleed:patch-1 branch from 39d79e4 to 12609e5 Mar 25, 2019

@robodoo robodoo added the CI 🤖 label Mar 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.