Contributors mailing list archives

contributors@odoo-community.org

Avatar

Re: Is there a way to create account.analytic.line from stock.move?

by
Radovan Skolnik
- 12/10/2020 19:19:57

Reading all the code I got all confused - you're right it's there in stock_account.

 

Initially I wanted to report that the code you provided does not seem to work for me - the stock move inside stock picking associated with Sale Order does not receive analytical account information. But I found the culprit later on. The part of code that I initially thought is alredy present in procurement_mto_analytic is this:

 

def _prepare_procurement_values(self, group_id=False):

        res = super()._prepare_procurement_values(group_id)
        res.update({"account_analytic_id": self.order_id.analytic_account_id.id})
        return res


However what you posted was this:

res.update({"analytic_account_id": self.order_id.analytic_account_id.id})

 

In stock_analytic (in fact in sale) the field is named analytic_account_id but in procurement_mto_analytic it's account_analytic_id. I missed this detail initially and of course it didn't work. Throughout the codebase of stock Odoo both names are used for some reason. The same goes for account-analytic OCA repository.

 

Best regards

 

Radovan

 

On pondelok 12. októbra 2020 17:02:34 CEST Dominique k wrote:

> look at the module stock_account

> Regards, Dominique

> On Mon, 12 Oct 2020 at 20:05, Radovan Skolnik < radovan@skolnik.info [1] >

> wrote: Oh, now I see (after long staring at various pieces of code).

> Account Move (account.move) ensures creation of Analytic Entries

> (account.analytic.line) for Account Move Lines (account.move.line) that are

> validated. So that way OCA module stock_analytic provides the possibility

> to create Analytic Entries in _prepare_account_move_line method...

>

> OK, now I'll update the code of procurement_mto_analytic (actually only the

> second part as the first part is there already - or should that be another

> module or even a new one?) with the code you provided, the analytical

> account value should be propagated into stock move lines. Now does stock

> move somehow relate to account move (to generate analytic entries)? Does

> not seem to me so...

>

> Thank you very much for info. Best regards

>

> Radovan

>

> On pondelok 12. októbra 2020 12:26:51 CEST Dominique k wrote:

> > in odoo standard, analytic entries (account.analytic.line) are generated

> > with journal entries (== invoices in v13 onwards). It is also possible to

> > create analytic entries separately, typically with timesheet. In fact

> > timesheet entries are analytic lines with the OCA module stock_analytic,

> > analytic entries are created when a stock move is validated. that is all

> > as

> > far as i know. other modules, do not generate analytic lines, instead,

> > they

> > add an analytic account to a document, which eventually ends up/link up

> > as/with a timesheet, an invoice or a stock move. Regards, Dominique

> > _______________________________________________

> > Mailing-List: https://odoo-community.org/groups/contributors-15 [2] [1]

> > Post to: mailto: contributors@odoo-community.org [3]

> > Unsubscribe: https://odoo-community.org/groups?unsubscribe [4] [2]

> >

> >

> >

> > [1] https://odoo-community.org/groups/contributors-15 [5]

> > [2] https://odoo-community.org/groups?unsubscribe [6]

>

> _______________________________________________

> Mailing-List: https://odoo-community.org/groups/contributors-15 [7]

> Post to: mailto:contributors@odoo-community.org

> Unsubscribe: https://odoo-community.org/groups?unsubscribe [8]

>

>

>

> [1] mailto:radovan@skolnik.info

> [2] https://odoo-community.org/groups/contributors-15

> [3] mailto:contributors@odoo-community.org

> [4] https://odoo-community.org/groups?unsubscribe

> [5] https://odoo-community.org/groups/contributors-15

> [6] https://odoo-community.org/groups?unsubscribe

> [7] https://odoo-community.org/groups/contributors-15

> [8] https://odoo-community.org/groups?unsubscribe

 

 

Reference