Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

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

by
dominique.k
- 12/10/2020 11:27:05
indeed. We added few lines of code to propagate the analytic account from SO to stock move. Not sure why it is not a module in OCA. May be because it is very small, and has to rely on a "glue" module ('sale_stock')

Anyway, if you add this (v13), in your code, it would work.
(you also need to add a dependency to 'sale_stock' in your manifest


class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'

    def _prepare_procurement_values(self, group_id=False):
        res = super(SaleOrderLine, self)._prepare_procurement_values(group_id=group_id)
        analytic_id = self.order_id.analytic_account_id
        res['analytic_account_id'] = analytic_id and analytic_id.id or False
        return res


class StockRule(models.Model):
    _inherit = 'stock.rule'

    def _get_custom_move_fields(self):
        fields = super(StockRule, self)._get_custom_move_fields()
        fields += ['analytic_account_id']
        return fields

Regards,
Dominique


On Mon, 12 Oct 2020 at 16:57, Radovan Skolnik <radovan@skolnik.info> wrote:
Aaron,

I cannot seem to get analytic_account_id propagated from SO to outgoing stock 
moves (also from PO to incoming stock moves). Is that supposed to work that 
way? When PO is created from SO the value is propagated there though.

Best regards

	Radovan

On štvrtok 8. októbra 2020 17:52:24 CEST Aarón Henríquez Quintana wrote:


> Yes, sorry for that. It only creates analytic entries if you use real time


> inventory valuation. Regards.


> On Thu, 8 Oct 2020 at 13:52, Radovan Skolnik < radovan@skolnik.info [1] >


> wrote: Thanx Aaron for info. But do I understand it correctly that this


> only propagates analytic account value into different objects but does not


> create account.analytic.line records? I need to get cost of products into


> them as negative amounts to be able to calulate profitability of analytic


> account. Best regards


> Radovan


> 


> On štvrtok 8. októbra 2020 10:42:06 CEST Aarón Henríquez Quintana wrote:


> > Yes. It is possible. You need a couple of modules:


> >  https://apps.odoo.com/apps/modules/12.0/stock_analytic/ [2] [1] adds the


> > 


> > analytic account to the stock move.


> > 


> >  https://github.com/ForgeFlow/eficent-odoo-addons/tree/12.0/purchase_stock


> >  _a [3]> 


> > nalytic [2] I use this for passing the analytic form the PO lines to the


> > stock moves. I think there is a similar one in the OCA apps but I don't


> > remember what it is called.


> > 


> >  https://github.com/OCA/account-analytic/tree/12.0/procurement_mto_analyti


> >  c [4]> 


> > [3] To pass the analytic information from the SO to the stock moves of the


> > delivery. Regards.


> > On Thu, 8 Oct 2020 at 10:17, Radovan Skolnik <  radovan@skolnik.info [5]


> > [4] > wrote: Hello,


> > we would like to use analytic accounts to track profitability of


> > individual


> > sales. So I'd setup automatic creation of analytic account on confirmed


> > sale orders which would be propagated to invoices. This would cover the


> > credit side. What I am struggling with is the debit side - i.e. costs of


> > products. One way would be adding analytic account on POs/POLs but that


> > is not feasible because we can have products in stock from past which we


> > decide to sell. So my idea is to generate account.analytic.line records


> > from stock.moves and assign them value according to average value. Are


> > there any modules that would support this? Or should I choose different


> > approach? Thank you. Best regards


> > Radovan Skolnik


> > 


> > 


> > _______________________________________________


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


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


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


> > 


> > 


> > _______________________________________________


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


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


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


> > 


> > 


> > 


> > [1]  https://apps.odoo.com/apps/modules/12.0/stock_analytic/ [12]


> > [2]


> > 


> >  https://github.com/ForgeFlow/eficent-odoo-addons/tree/12.0/purchase_stock


> >  _a [13]> 


> > nalytic [3]


> > 


> >  https://github.com/OCA/account-analytic/tree/12.0/procurement_mto_analyti


> >  c [14]> 


> > [4] mailto: radovan@skolnik.info [15]


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


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


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


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


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


> 


> _______________________________________________


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


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


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


> 


> 


> _______________________________________________


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


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


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


> 


> 


> 


> [1] mailto:radovan@skolnik.info


> [2] https://apps.odoo.com/apps/modules/12.0/stock_analytic/


> [3]


> https://github.com/ForgeFlow/eficent-odoo-addons/tree/12.0/purchase_stock_a


> [4]


> https://github.com/OCA/account-analytic/tree/12.0/procurement_mto_analytic


> [5] mailto:radovan@skolnik.info


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


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


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


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


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


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


> [12] https://apps.odoo.com/apps/modules/12.0/stock_analytic/


> [13]


> https://github.com/ForgeFlow/eficent-odoo-addons/tree/12.0/purchase_stock_a


> [14]


> https://github.com/OCA/account-analytic/tree/12.0/procurement_mto_analytic


> [15] mailto:radovan@skolnik.info


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


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


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


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


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


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


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


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


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


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




_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

Reference