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

[9.0] stock_picking_invoice_link: redo migration from 8.0 to 9.0 #296

Merged
merged 9 commits into from
Jun 15, 2017

Conversation

jbaudoux
Copy link
Contributor

Previous migration did not keep the business functionnality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial deivery.

The previous port of this module changed the purpose of the module that is to link invoice (and lines) to the related picking (moves) to allows to find out exactly what move is invoiced. This was broken as each invoice was linked to all deliveries of all related sales orders.

I reverted the code to the original functionality in v8.0 and performed again the migration to the v9.0.
From version 9.0, you invoice always from the sale order based on quantites to invoice. With this module, you can know exactly what delivery is in the invoice.

@jbaudoux jbaudoux changed the title [9.0] stock_picking_invoice_link: redo migration from 8.0 to 9.0. [9.0] stock_picking_invoice_link: redo migration from 8.0 to 9.0. - WIP Jan 31, 2017
@jbaudoux
Copy link
Contributor Author

jbaudoux commented Jan 31, 2017

This module fix the previous port here: #261

@elicoidal
Copy link

Can you recheck Travis status?

@jbaudoux
Copy link
Contributor Author

jbaudoux commented Feb 1, 2017

@elicoidal I'm trying to get the test working which proves that the module does what is expected. That's why I kept the PR in WIP for now. I'll remove the WIP status and notify when it's working.

Copy link

@elicoidal elicoidal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some details on README and an important question on the SQL usage

@@ -44,6 +42,7 @@ Contributors
* Unai Alkorta
* Iñaki Zabala
* Oihane Crucelaegui <[email protected]>
* Jacques-Etienne Baudoux <[email protected]>

Maintainer
----------

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update below to the newest README template

string='Related Pickings', readonly=True,
copy=False,
help="Related pickings "
"(only when the invoice has been generated from the picking).")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/picking/pickings

comodel_name='stock.move', inverse_name='invoice_line_id',
string='Related Stock Moves', readonly=True,
help="Related stock moves "
"(only when the invoice has been generated from the picking).")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/picking/pickings

@api.multi
def _prepare_invoice_line(self, qty):
vals = super(SaleOrderLine, self)._prepare_invoice_line(qty)
# move_ids = self.procurement_ids.mapped('move_ids').filtered(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove dead code

# x.location_dest_id.usage == 'customer').ids

# For performance reason, we compute the list of move in SQL
self._cr.execute("""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I raise a strong warning here against this SQL statement!
This is bypassing all ACL (customer, multi-company etc.)
@pedrobaeza

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm sure this is not really needed to be in SQL. In previous version it doesn't.

@jbaudoux
Copy link
Contributor Author

jbaudoux commented Feb 1, 2017

Thanks for you comments. I'm not sure of the best approach to keep performance if you generate invoices end of month for thousands of sales orders.

@pedrobaeza
Copy link
Member

Well, the approach is always to make it work first, and then see performance bottlenecks to try to improve.

@jbaudoux jbaudoux changed the title [9.0] stock_picking_invoice_link: redo migration from 8.0 to 9.0. - WIP [9.0] stock_picking_invoice_link: redo migration from 8.0 to 9.0 Feb 2, 2017
@jbaudoux
Copy link
Contributor Author

jbaudoux commented Feb 2, 2017

@elicoidal @pedrobaeza Module is now working properly. I removed WIP status.

@elicoidal
Copy link

some small details left on the README file. Other than that LGTM

@jbaudoux
Copy link
Contributor Author

@elicoidal Can you explain what should be improved in the README file, I can see anything missing or wrong?

@elicoidal
Copy link

one URL AFAICS.
Good job!

@jjscarafia
Copy link
Contributor

If I understand this right, this will break actual behavior and will only works for newly created pickings.

A nice to have would be a post install script that could be used also in a upgrade script for actual v9 module that, at least, build a link for all invoices (actual v9 behavior).

comodel_name='stock.picking', string='Related Pickings', readonly=True,
copy=False,
help="Related pickings "
"(only when the invoice has been generated from the picking).")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinks this sould be "help="Related pickings " (only when the invoice has been generated from a sale order)".

readonly=True,
copy=False,
help="Related stock moves "
"(only when the invoice has been generated from the picking).")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinks this sould be "help="Related pickings " (only when the invoice has been generated from a sale order)".

groups="account.group_account_invoice"
attrs="{'invisible':[('invoice_ids', '=', False)]}"
widget="many2many_tags"
context="{'tree_view_ref': 'account.invoice_tree', 'form_view_ref': 'invoice_form'}"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As explain in this pr https://github.com/OCA/stock-logistics-workflow/pull/319/files , full reference is required so customer invoice form is correctly displayed. Use "stock_picking_invoice_link.invoice_form" instead of "invoice_form".

@jbaudoux jbaudoux force-pushed the 9.0-fixmig-stock_picking_invoice_link branch from 50ec010 to 44f7bcf Compare April 4, 2017 12:44
@eLBati
Copy link
Member

eLBati commented Apr 10, 2017

Hello @jbaudoux I can't reproduce the problem:

  • Created a SO with 2 lines (2 products with Invoicing Policy = Delivered quantities)
  • Delivered 1 line and created back order
  • Invoiced the done delivery order

Tab 'pickings' of the invoice contains only 1 picking

  • Completely transferred the back order

Tab 'pickings' of the invoice contains only 1 picking

  • From the SO, Invoiced the remaining quantities

Both invoices, in 'pickings' tab, contain only 1 picking

@eLBati
Copy link
Member

eLBati commented Apr 10, 2017

@jbaudoux I looked at the tests and reproduced manually:

  • Created a SO with 2 products (with Invoicing Policy = Delivered quantities) and quantities = 2
  • Partially delivered the picking (quantity = 1 for both lines)
  • Created invoice

'pickings' tab of the invoice has 2 pickings, while it should only contain the 'done' one.

I'm going to review the changes now.

Thanks

Copy link
Member

@eLBati eLBati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@eLBati
Copy link
Member

eLBati commented Apr 10, 2017

@jjscarafia Fields account.invoice.picking_ids and account.invoice.line.move_line_ids will be empty after updating to this new version of the module, in existing DBs.

I suspect they can't be correctly computed, as the information is lost at the moment of invoice creation (see methods invoice_line_create and _prepare_invoice_line of sale.order.line).
@jbaudoux am I right?

We could write it in README, explaining how to retrieve the old (in some cases wrong) values, using the old version of the fields:

class AccountInvoice(models.Model):
    _inherit = "account.invoice"

    old_version_picking_ids = fields.Many2many(
        comodel_name='stock.picking', string='Related Pickings (old version)',
        compute="_compute_picking_ids")

    @api.multi
    def _compute_picking_ids(self):
        for invoice in self:
            invoice.picking_ids = self.env['stock.picking']
            for line in invoice.invoice_line_ids:
                invoice.picking_ids |= line.move_line_ids.mapped('picking_id')


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

    old_version_move_line_ids = fields.Many2many(
        comodel_name='stock.move', string='Related Stock Moves (old version)',
        compute="_compute_move_line_ids")

    @api.multi
    def _compute_move_line_ids(self):
        for line in self:
            line.move_line_ids = self.env['stock.move']
            for sale_line in line.sale_line_ids:
                for proc in sale_line.procurement_ids:
                    line.move_line_ids |= proc.move_ids

What do you think?

manuelcalerosolis pushed a commit to Tecnativa/stock-logistics-workflow that referenced this pull request Mar 12, 2020
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
sergio-teruel pushed a commit to Tecnativa/stock-logistics-workflow that referenced this pull request Jun 25, 2020
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
mileo pushed a commit to odoo-brazil/stock-logistics-workflow that referenced this pull request Oct 21, 2020
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
joao-p-marques pushed a commit to Tecnativa/stock-logistics-workflow that referenced this pull request Jan 7, 2021
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
antonyht27 pushed a commit to antonyht27/stock-logistics-workflow that referenced this pull request Jan 12, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
robin5210 pushed a commit to robin5210/stock-logistics-workflow that referenced this pull request Feb 15, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Jun 21, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Jun 22, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Jul 28, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Aug 23, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Aug 23, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Sep 15, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Sep 15, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
JT-Odoo pushed a commit to JT-Odoo/stock-logistics-workflow that referenced this pull request Oct 14, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Nov 4, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Nov 4, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Nov 22, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
nicomacr pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Nov 22, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
CarlosRoca13 pushed a commit to Tecnativa/stock-logistics-workflow that referenced this pull request Dec 2, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
CarlosRoca13 pushed a commit to Tecnativa/stock-logistics-workflow that referenced this pull request Dec 2, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
JoelZilli pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Dec 13, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
JoelZilli pushed a commit to adhoc-dev/stock-logistics-workflow that referenced this pull request Dec 13, 2022
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
sergio-teruel pushed a commit to Tecnativa/stock-logistics-workflow that referenced this pull request Jan 25, 2023
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
sergio-teruel pushed a commit to Tecnativa/stock-logistics-workflow that referenced this pull request Jan 25, 2023
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
lethuthao2403 pushed a commit to lethuthao2403/stock-logistics-workflow that referenced this pull request Nov 29, 2023
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
lethuthao2403 pushed a commit to lethuthao2403/stock-logistics-workflow that referenced this pull request Nov 29, 2023
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
carlosdynapps pushed a commit to carlosdynapps/stock-logistics-workflow that referenced this pull request Oct 31, 2024
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
carlosdynapps pushed a commit to carlosdynapps/stock-logistics-workflow that referenced this pull request Oct 31, 2024
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
adhoc-cicd-bot pushed a commit to adhoc-cicd/oca-stock-logistics-workflow that referenced this pull request Jan 10, 2025
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
adhoc-cicd-bot pushed a commit to adhoc-cicd/oca-stock-logistics-workflow that referenced this pull request Jan 10, 2025
…#296)

Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants