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

[v10] Contracts Management - Recurring: wrong value for account ID #59

Closed
m3dbedb opened this issue Apr 5, 2017 · 28 comments
Closed

[v10] Contracts Management - Recurring: wrong value for account ID #59

m3dbedb opened this issue Apr 5, 2017 · 28 comments
Labels
Milestone

Comments

@m3dbedb
Copy link

m3dbedb commented Apr 5, 2017

After installation of "Contracts Management - Recurring" module, I create contract for demo customer agrolait, and when I try to create and save invoice for the contract, odoo say
" File "C:\Program Files (x86)\Odoo 10.0\server\odoo\fields.py", line 2011, in convert_to_cache
ValueError: Wrong value for account.invoice.analytic_account_ids: 7"
Same error found in runbot of odoo community.
contr

@woodbrettm
Copy link

@m3dbedb similar issue here as well. @lasley

  • Install Contract
  • Go to Invoicing, Contracts, Contract Templates.
  • Add an invoice line
  • Select [CARD] Graphics Card
  • Following Error appears:
Traceback (most recent call last):
  File "/opt/odoo/odoo/http.py", line 638, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo/http.py", line 675, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo/http.py", line 331, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo/service/model.py", line 119, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo/http.py", line 324, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo/odoo/http.py", line 933, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo/http.py", line 504, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/addons/web/controllers/main.py", line 862, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/addons/web/controllers/main.py", line 854, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/odoo/api.py", line 681, in call_kw
    return call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo/odoo/api.py", line 672, in call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/odoo/models.py", line 5460, in onchange
    record._onchange_eval(name, field_onchange[name], result)
  File "/opt/odoo/odoo/models.py", line 5358, in _onchange_eval
    method_res = method(self)
  File "/media/sf_odoo10dev/contract/contract/models/account_analytic_invoice_line.py", line 85, in _onchange_product_id
    vals['price_unit'] = product.price
  File "/opt/odoo/odoo/fields.py", line 868, in __get__
    self.determine_value(record)
  File "/opt/odoo/odoo/fields.py", line 979, in determine_value
    self.compute_value(recs)
  File "/opt/odoo/odoo/fields.py", line 934, in compute_value
    self._compute_value(records)
  File "/opt/odoo/odoo/fields.py", line 926, in _compute_value
    getattr(records, self.compute)()
  File "/opt/odoo/addons/product/models/product.py", line 187, in _compute_product_price
    prices = pricelist.get_products_price(self, quantities, partners)
  File "/opt/odoo/addons/product/models/product_pricelist.py", line 254, in get_products_price
    return dict((product_id, res_tuple[0]) for product_id, res_tuple in self._compute_price_rule(zip(products, quantities, partners), date=date, uom_id=uom_id).iteritems())
  File "/opt/odoo/addons/product/models/product_pricelist.py", line 154, in _compute_price_rule
    (prod_tmpl_ids, prod_ids, categ_ids, self.id, date, date))
  File "/opt/odoo/odoo/sql_db.py", line 141, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/odoo/odoo/sql_db.py", line 218, in execute
    res = self._obj.execute(query, params)
ProgrammingError: operator does not exist: date <= boolean
LINE 1: ...1) AND (item.date_start IS NULL OR item.date_start<=false) A...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

@pedrobaeza
Copy link
Member

Is this fixed?

@woodbrettm
Copy link

woodbrettm commented Aug 23, 2017

I'd imagine so. Mine ended up being unrelated and I've added invoice lines since then and it seems fine.

lasley added a commit to LasLabs/contract that referenced this issue Aug 23, 2017
* Update contract template lines handling to fix OCA#80, and fix OCA#59
@lasley
Copy link
Contributor

lasley commented Aug 23, 2017

#92 should do the trick. Amended the commit to include this ticket

@lasley lasley added the bug label Aug 23, 2017
@lasley lasley added this to the 10.0 milestone Aug 23, 2017
@primes2h
Copy link
Contributor

primes2h commented Sep 19, 2017

I've just tried a locally patched version with all those 5 commit (#92) Unfortunately it doesn't fix the issue.

Just to add more info, this is the error log from runbot:

  File "/.repo_requirements/odoo/odoo/http.py", line 640, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/.repo_requirements/odoo/odoo/http.py", line 677, in dispatch
    result = self._call_function(**self.params)
  File "/.repo_requirements/odoo/odoo/http.py", line 333, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/.repo_requirements/odoo/odoo/service/model.py", line 101, in wrapper
    return f(dbname, *args, **kwargs)
  File "/.repo_requirements/odoo/odoo/http.py", line 326, in checked_call
    result = self.endpoint(*a, **kw)
  File "/.repo_requirements/odoo/odoo/http.py", line 935, in __call__
    return self.method(*args, **kw)
  File "/.repo_requirements/odoo/odoo/http.py", line 506, in response_wrap
    response = f(*args, **kw)
  File "/home/odoo/odoo-10.0/addons/web/controllers/main.py", line 885, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/home/odoo/odoo-10.0/addons/web/controllers/main.py", line 877, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/.repo_requirements/odoo/odoo/api.py", line 687, in call_kw
    return call_kw_model(method, model, args, kwargs)
  File "/.repo_requirements/odoo/odoo/api.py", line 672, in call_kw_model
    result = method(recs, *args, **kwargs)
  File "/home/odoo/dependencies/bank-payment/account_payment_partner/models/account_invoice.py", line 62, in create
    return super(AccountInvoice, self).create(vals)
  File "/home/odoo/odoo-10.0/addons/account/models/account_invoice.py", line 345, in create
    invoice = super(AccountInvoice, self.with_context(mail_create_nolog=True)).create(vals)
  File "/home/odoo/odoo-10.0/addons/mail/models/mail_thread.py", line 228, in create
    thread = super(MailThread, self).create(values)
  File "/.repo_requirements/odoo/odoo/models.py", line 3806, in create
    vals = self._add_missing_default_values(vals)
  File "/.repo_requirements/odoo/odoo/models.py", line 1639, in _add_missing_default_values
    defaults = self.default_get(list(missing_defaults))
  File "/.repo_requirements/odoo/odoo/models.py", line 1131, in default_get
    defaults = self._convert_to_write(defaults)
  File "/.repo_requirements/odoo/odoo/models.py", line 4931, in _convert_to_write
    value = field.convert_to_cache(value, self, validate=False)
  File "/.repo_requirements/odoo/odoo/fields.py", line 2013, in convert_to_cache
    raise ValueError("Wrong value for %s: %s" % (self, value))
ValueError: Wrong value for account.invoice.analytic_account_ids: 12```

@primes2h
Copy link
Contributor

primes2h commented Sep 19, 2017

And this is from a locally patched module:

  File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 640, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 677, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 333, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 101, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 326, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 935, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 506, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/odoo/addons/web/controllers/main.py", line 885, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/usr/lib/python2.7/dist-packages/odoo/addons/web/controllers/main.py", line 877, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/usr/lib/python2.7/dist-packages/odoo/api.py", line 687, in call_kw
    return call_kw_model(method, model, args, kwargs)
  File "/usr/lib/python2.7/dist-packages/odoo/api.py", line 672, in call_kw_model
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/odoo/addons/account/models/account_invoice.py", line 345, in create
    invoice = super(AccountInvoice, self.with_context(mail_create_nolog=True)).create(vals)
  File "/usr/lib/python2.7/dist-packages/odoo/addons/mail/models/mail_thread.py", line 228, in create
    thread = super(MailThread, self).create(values)
  File "/usr/lib/python2.7/dist-packages/odoo/models.py", line 3806, in create
    vals = self._add_missing_default_values(vals)
  File "/usr/lib/python2.7/dist-packages/odoo/models.py", line 1639, in _add_missing_default_values
    defaults = self.default_get(list(missing_defaults))
  File "/usr/lib/python2.7/dist-packages/odoo/addons/utm/models/utm.py", line 61, in default_get
    values = super(UtmMixin, self).default_get(fields)
  File "/usr/lib/python2.7/dist-packages/odoo/models.py", line 1131, in default_get
    defaults = self._convert_to_write(defaults)
  File "/usr/lib/python2.7/dist-packages/odoo/models.py", line 4931, in _convert_to_write
    value = field.convert_to_cache(value, self, validate=False)
  File "/usr/lib/python2.7/dist-packages/odoo/fields.py", line 2013, in convert_to_cache
    raise ValueError("Wrong value for %s: %s" % (self, value))
ValueError: Wrong value for account.invoice.analytic_account_ids: 9

@lasley
Copy link
Contributor

lasley commented Sep 19, 2017

@primes2h - You tested the Runbot that was built on #92? It was expired long ago and didn't have logs available, so I think you were not on it.

I rebuilt and retested - invoices are generating fine. Can you please test using the Runbot that is currently available in the #92 PR and let me know replication steps if it does not work?

@primes2h
Copy link
Contributor

@lasley The previous log from runbot was just to add some info about the bug itself.
Only the second log reported was from a patched module.

Anyway I've just tested the new runbot based on #92 PR and the bug is still there.
Steps to reproduce:

  1. Click on Invoicing, Sales→Contracts
  2. Open the existing Contract
  3. Click on "Invoices" button in the upper-right side
    immagine
  4. Create a new invoice
  5. Fill in data in the the new invoice
  6. Save

@lasley
Copy link
Contributor

lasley commented Sep 19, 2017

@primes2h - I don't think that is a supported method of creating the invoices, because they won't contain the proper contract information. Keep in mind that this module is for automatic invoice creation, not manual.

We do have a way to create the invoices for testing though (or one-off invoice creations), which will use the same processes that the cron does. You'll need to enable developer mode, then a Create Invoices link appears:

image

@primes2h
Copy link
Contributor

primes2h commented Sep 19, 2017

You are talking about recurring invoice, and I know that works in that way "if" you select "Generate recurring invoices automatically".

But it's a choice, you could need some contracts with recurring invoices (using the checkbox) and some without (leaving it blank), and add some contract invoice manually.

If you try to add another contract (with no recurring invoice) the error come up as well.

So it's definitely a bug.

If the module is intended to be for automatic invoice creation, you should remove "Generate recurring invoice" checkbox in my opinion.

@lasley
Copy link
Contributor

lasley commented Sep 19, 2017

@primes2h - The "Invoices" button is provided by the contract_show_invoice module, but creation is not within the scope in that ReadMe. Contracts are typically naive of the invoices that they create - the contract_show_invoice is honestly just kind of a hack to get you to see the invoices (it's just a search on the pre-existing invoice view filtered for the proper analytic account ID).

It sounds like you're going a bit outside of the admittedly tiny box that these modules cover. Would you mind elaborating a bit more on your use case? It sounds like you may be interested in the work being done to expand the scope of this repo

@primes2h
Copy link
Contributor

If the module is intended to be for automatic recurring invoice creation (and not manual), you should remove "Generate recurring invoice" checkbox in my opinion.

@lasley
Copy link
Contributor

lasley commented Sep 19, 2017

@primes2h - The issue is that contracts are analytic accounts. You are looking at an analytic account view when you're looking at the contracts, so the checkbox is required to add the automation logic to those analytic accounts. This is what the mailing list thread I referenced is about - the current design is not really that good, but it's what we have right now.

We could maybe default the checkbox to True when in the contracts view though. Do you think that would help? Or maybe something else?

@lasley
Copy link
Contributor

lasley commented Sep 19, 2017

It's also worth noting that invoices can be created and assigned to contracts, because they are analytic accounts.

You'll need to enable analytic accounting though I think, because it would be on the line items of the invoices and not the invoices themselves. @pedrobaeza correct me if I'm wrong here

@primes2h
Copy link
Contributor

It "worths" in my opinion because invoices could belong to a contract and so be grouped together.
If you need to know what invoices come from that Contract, you can open the contract itself and click on the Invoices button on the upper-right side (in fact this is the purpose of that button, isn't it?)

Going back to this kind of bug, what I would like to explain is that, generally speaking, a module should be self-consistent.
If a traceback come up on the screen just after clicking the save button, I think it's definitely a bug, regardless the way you reach that point.

@carlosdauden
Copy link
Contributor

carlosdauden commented Sep 19, 2017

This problem is caused by the module contract_show_invoice

[active_id], 'default_analytic_account_ids': active_id}</field>
with missing brackets and attempt assign default value to compute field
analytic_account_ids = fields.Many2many(
comodel_name='account.analytic.account',
compute='_compute_analytic_account_ids',
store=True,
string='Contracts')
@api.multi
@api.depends('invoice_line_ids.account_analytic_id')
def _compute_analytic_account_ids(self):
for invoice in self:
invoice.analytic_account_ids = invoice.mapped(
'invoice_line_ids.account_analytic_id'
)

BTW I think this module should not be in this repository because the module links analytic info, the contract field is

contract_id = fields.Many2one(

@primes2h
Copy link
Contributor

primes2h commented Sep 19, 2017

You can reproduce the bug without that module (contract_show_invoice) installed.

Anyway I tried to install it but the bug is still there, nothing changed.

Anyway, I'll try to do some debug later, I hope to find something useful to fix this bug.

@lasley
Copy link
Contributor

lasley commented Sep 19, 2017

@primes2h - The Invoices button is introduced in contract_show_invoice. How are you reproducing the error without the Invoices button?

There is a "Show recurring invoices" link, but I was able to create an invoice using that one just fine & it linked properly.

@lasley
Copy link
Contributor

lasley commented Sep 19, 2017

Wait why the hell does a module exist to add a button for invoices, when we already have a link for invoices...

@pedrobaeza
Copy link
Member

For the invoices that have that analytic account, but not coming from recurring invoicing.

@lasley
Copy link
Contributor

lasley commented Sep 19, 2017

The Show recurring invoices link does that as well. I created an invoice after clicking that link, then went back and it was there (it's the Edward Foster one without a source document)

@pedrobaeza
Copy link
Member

Don't go through the button, but add an invoice through Accounting and select that analytic account in an invoice line.

@lasley
Copy link
Contributor

lasley commented Sep 19, 2017

Ohhhhhh interesting - it looks like contract_show_invoices has more bugs then, because it does not show the invoice I created (through Customer Invoices) either.

I did notice something though - if you create an invoice after clicking the link - it's a vendor invoice.

Creating a vendor invoice will show it in the Invoices link, but not the Show recurring invoices link as intended.

@carlosdauden
Copy link
Contributor

#84

@carlosdauden
Copy link
Contributor

@primes2h
Copy link
Contributor

@carlosdauden you were absolutely right! The problem was the missing brackets. I didn't realize that I was working on another local odoo installation on which the contract_show_invoice was installed

@primes2h
Copy link
Contributor

primes2h commented Sep 20, 2017

#99 does the trick to fix this bug

@primes2h
Copy link
Contributor

@lasley
yes, I confirm those bugs.

About the last one you reported, invoices are not linked with the contract itself (Source Document field is empty).

feketemihai pushed a commit to feketemihai/contract that referenced this issue Nov 13, 2017
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
pedrobaeza pushed a commit to feketemihai/contract that referenced this issue Nov 18, 2017
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
pedrobaeza pushed a commit to feketemihai/contract that referenced this issue Nov 19, 2017
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
pedrobaeza pushed a commit to feketemihai/contract that referenced this issue Nov 19, 2017
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
sbejaoui pushed a commit to sbejaoui/contract that referenced this issue Oct 25, 2018
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
pedrobaeza pushed a commit to sbejaoui/contract that referenced this issue Oct 27, 2018
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
sbejaoui pushed a commit to sbejaoui/contract that referenced this issue Jan 24, 2019
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
devCbssolutionsRo pushed a commit to devCbssolutionsRo/contract that referenced this issue Dec 19, 2019
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
AaronHForgeFlow pushed a commit to ForgeFlow/contract that referenced this issue Apr 24, 2020
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
pedrobaeza pushed a commit to Tecnativa/contract that referenced this issue Jul 14, 2020
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
ozono pushed a commit to ozono/contract that referenced this issue Nov 7, 2020
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
ozono pushed a commit to ozono/contract that referenced this issue Nov 14, 2020
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
dnplkndll pushed a commit to Kencove/contract that referenced this issue Dec 6, 2020
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
ozono pushed a commit to ozono/contract that referenced this issue Apr 2, 2021
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
jcdrubay pushed a commit to jcdrubay/contract that referenced this issue Oct 28, 2021
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
olgamarcocb pushed a commit to tegin/contract that referenced this issue Nov 16, 2021
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
wpichler pushed a commit to wpichler/contract that referenced this issue Oct 24, 2022
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
pedrobaeza pushed a commit to wpichler/contract that referenced this issue Mar 15, 2023
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
peluko00 pushed a commit to APSL/contract that referenced this issue Feb 15, 2024
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
jaydeep32 pushed a commit to archeti-org/contract that referenced this issue Feb 15, 2024
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
CRogos pushed a commit to c4a8-odoo/module-oca-contract that referenced this issue Mar 23, 2024
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
CRogos pushed a commit to c4a8-odoo/module-oca-contract that referenced this issue Mar 23, 2024
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
CRogos pushed a commit to c4a8-odoo/module-oca-contract that referenced this issue Mar 23, 2024
Update contract template lines handling to fix OCA#80, and fix OCA#59 OCA#100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants