Skip to content

Invoice FSM Order #628

Description

@hparfr

Hi,

There was a lot of discussion about it, I don't remind why we do it like that (I approved it). But, I have the feeling the actual design is not good.

There was :

class AccountInvoiceLine(models.Model):
    _inherit = 'account.invoice.line'

    fsm_order_ids = fields.One2many(
        comodel_name='fsm.order',
        inverse_name='invoice_line_id',
        string='FSM Orders',
        readonly=True, copy=False,
    )
...

class FSMOrder(models.Model):
    _inherit = 'fsm.order'

    invoice_line_id = fields.Many2one(
        comodel_name="account.invoice.line",
        readonly=True,
        copy=False,
    )

18cb3b1#diff-6cd1cb5cd4cb8da0f4d411f6132bc412R10

Then here : 923042f#diff-6cd1cb5cd4cb8da0f4d411f6132bc412 is has been changed to :

class AccountInvoiceLine(models.Model):
    _inherit = 'account.invoice.line'

    fsm_order_id = fields.Many2one('fsm.order', string='FSM Order')

And all merged here: #411

In #430 (comment) there is a discussion about this relation.

Today, I have the feeling that we should adopt the same strategy than in Sale orders : https://github.com/odoo/odoo/blob/13.0/addons/sale/models/sale.py#L1190

class AccountMoveLine(models.Model):
    _inherit = 'account.move.line'

    fsm_order_ids = fields.Many2many(
        'fsm.order',
        'fsm_order_account_move_line_rel',
        'invoice_line_id', 'order_line_id',
        string='FSM Orders', readonly=True, copy=False)
...

class FSMOrder(models.Model):
    _inherit = 'fsm.order'

    move_line_ids = fields.Many2many(
         'account.move.line',
         'fsm_order_account_move_line_rel',
         'fsm_order_id',
         'account_move_line_id', string='Invoice Lines', copy=False) 
  

...because it allows to:

  • invoice one FSM Order in one Invoice line
  • invoice multiple FSM Orders in one Invoice line (group per invoice line)
  • invoice multiple time the same FSM Order on different invoice (lines)
  • be consistent with sales module

What do you think ? @max3903 @brian10048

Metadata

Metadata

Assignees

No one assigned

    Labels

    stalePR/Issue without recent activity, it'll be soon closed automatically.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions