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

[14.0][MIG] purchase_order_line_sequence #1060

Merged
merged 22 commits into from
Jul 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
edfd65d
[IMP] renamed the module name.
SerpentCS Sep 26, 2016
37f4704
[ADD] added dependencies and sequences
SerpentCS Sep 28, 2016
59b8087
[IMP] test cases
serpentcs-dev1 Mar 6, 2017
b630584
[ADD] purchase_order_line_sequence v10
serpentcs-dev1 Jun 30, 2017
40897f2
[ADD] Missing dependency
jpoa Mar 15, 2018
0c7f587
[FIX] Bug in the logic of the module
jpoa Mar 26, 2018
fef5025
[FIX] Assure sequence of stock moves are the same as of po lines
MiquelRForgeFlow Jul 26, 2018
e2bcd0c
[FIX] Correct a test. Products are in purchase_method 'receive'
MiquelRForgeFlow Jul 26, 2018
29b4b4b
[UPD] Update purchase_order_line_sequence.pot
oca-travis Jul 30, 2018
939e6a6
[FIX] Make module compatible with other reporting modules
MiquelRForgeFlow Sep 20, 2018
994b076
[MIG] purchase_order_line_sequence to version 12
bjeficent Nov 26, 2018
a7081fe
[UPD] Update purchase_order_line_sequence.pot
oca-travis Mar 11, 2020
73add6e
[UPD] README.rst
OCA-git-bot Mar 11, 2020
5ed6329
[ADD] icon.png
OCA-git-bot Mar 11, 2020
7304f0a
Update translation files
oca-transbot Mar 11, 2020
a17cd31
[FIX]purchase_order_line_sequence. Do not update move sequence in mov…
AaronHForgeFlow Dec 18, 2019
85efd09
purchase_order_line_sequence 12.0.1.0.1
OCA-git-bot Apr 14, 2020
d3b9b08
Update translation files
oca-transbot Aug 16, 2020
599e022
Translated using Weblate (French)
SandieFavre Aug 28, 2020
c259180
[IMP] purchase_order_line_sequence: black, isort, prettier
cjallais Feb 3, 2021
0d84b1b
[MIG] purchase_order_line_sequence: Migration to 14.0
cjallais Jan 7, 2021
7706f8c
Merge branch '14.0' into 14.0-purchase_order_line_sequence
cjallais May 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
server-ux
stock-logistics-workflow
product-attribute
94 changes: 94 additions & 0 deletions purchase_order_line_sequence/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
============================
Purchase Order Line Sequence
============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_line_sequence
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_order_line_sequence
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/142/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|


The sequence in PO line is propagated to the Stock moves. The sequence number
appears in the PO form view and in the report.

**Table of contents**

.. contents::
:local:

Usage
=====


This module depends on the following module(s) :
* stock_picking_line_sequence (https://github.com/OCA/stock-logistics-workflow/)

Known issues / Roadmap
======================


In standard odoo is possible to sort the purchase order lines and those are propagated to the invoice lines

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_order_line_sequence%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Camptocamp
* Eficent
* Serpent CS

Contributors
~~~~~~~~~~~~


* Cécile Jallais <cjallais@archeti.com>
* Damien Crier <damien.crier@camptocamp.com>
* Eficent Business and IT Consulting Services S.L. <contact@eficent.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_line_sequence>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions purchase_order_line_sequence/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import models
from .hooks import post_init_hook
30 changes: 30 additions & 0 deletions purchase_order_line_sequence/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2017 Camptocamp SA - Damien Crier, Alexandre Fayolle
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Purchase Order Line Sequence",
"summary": "Adds sequence to PO lines and propagates it to"
"Invoice lines and Stock Moves",
"version": "14.0.1.0.0",
"category": "Purchase Management",
"author": "Camptocamp, "
"Eficent, "
"Serpent CS, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/purchase-workflow",
"depends": [
"purchase_stock",
"stock_picking_line_sequence",
],
"data": [
"views/purchase_view.xml",
"views/report_purchaseorder.xml",
"views/report_purchasequotation.xml",
],
"post_init_hook": "post_init_hook",
"installable": True,
"auto_install": False,
"license": "AGPL-3",
}
15 changes: 15 additions & 0 deletions purchase_order_line_sequence/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import SUPERUSER_ID
from odoo.api import Environment


def post_init_hook(cr, pool):
"""
Fetches all the PO and resets the sequence of the purchase order lines.
"""
env = Environment(cr, SUPERUSER_ID, {})
purchase = env["purchase.order"].search([])
purchase._reset_sequence()
67 changes: 67 additions & 0 deletions purchase_order_line_sequence/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_order_reorder_lines
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-10 13:13+0000\n"
"PO-Revision-Date: 2020-08-28 17:00+0000\n"
"Last-Translator: Sandie FAVRE <sandie.favre@grap.coop>\n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 3.10\n"

#. module: purchase_order_line_sequence
#: model_terms:ir.ui.view,arch_db:purchase_order_line_sequence.report_purchase_order_sequence_qweb
#: model_terms:ir.ui.view,arch_db:purchase_order_line_sequence.report_purchase_quote_sequence_qweb
msgid "<strong>Sequence</strong>"
msgstr "Séquence"

#. module: purchase_order_line_sequence
#: model:ir.model.fields,help:purchase_order_line_sequence.field_purchase_order_line__sequence2
msgid "Displays the sequence of the line in the purchase order."
msgstr "Affiche la séquence de la ligne dans l'ordre d'achat."

#. module: purchase_order_line_sequence
#: model:ir.model.fields,help:purchase_order_line_sequence.field_purchase_order_line__sequence
msgid "Gives the sequence of the line when displaying the purchase order."
msgstr "Donne la séquence de la ligne lors de l'affichage du bon de commande."

#. module: purchase_order_line_sequence
#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order_line__sequence
msgid "Hidden Sequence"
msgstr "Séquence masquée"

#. module: purchase_order_line_sequence
#: model:ir.model,name:purchase_order_line_sequence.model_account_invoice_line
msgid "Invoice Line"
msgstr "Ligne de facture"

#. module: purchase_order_line_sequence
#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order__max_line_sequence
msgid "Max sequence in lines"
msgstr ""

#. module: purchase_order_line_sequence
#: model:ir.model,name:purchase_order_line_sequence.model_purchase_order
msgid "Purchase Order"
msgstr "Bon de commande"

#. module: purchase_order_line_sequence
#: model:ir.model,name:purchase_order_line_sequence.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Ligne de bon de commande"

#. module: purchase_order_line_sequence
#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order_line__sequence2
msgid "Sequence"
msgstr "Séquence"

#~ msgid "Purchase Order Line Make Invoice"
#~ msgstr "Créer la facture des lignes de commande d'achat"
61 changes: 61 additions & 0 deletions purchase_order_line_sequence/i18n/purchase_order_line_sequence.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_order_line_sequence
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: purchase_order_line_sequence
#: model_terms:ir.ui.view,arch_db:purchase_order_line_sequence.report_purchase_order_sequence_qweb
#: model_terms:ir.ui.view,arch_db:purchase_order_line_sequence.report_purchase_quote_sequence_qweb
msgid "<strong>Sequence</strong>"
msgstr ""

#. module: purchase_order_line_sequence
#: model:ir.model.fields,help:purchase_order_line_sequence.field_purchase_order_line__sequence2
msgid "Displays the sequence of the line in the purchase order."
msgstr ""

#. module: purchase_order_line_sequence
#: model:ir.model.fields,help:purchase_order_line_sequence.field_purchase_order_line__sequence
msgid "Gives the sequence of the line when displaying the purchase order."
msgstr ""

#. module: purchase_order_line_sequence
#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order_line__sequence
msgid "Hidden Sequence"
msgstr ""

#. module: purchase_order_line_sequence
#: model:ir.model,name:purchase_order_line_sequence.model_account_invoice_line
msgid "Invoice Line"
msgstr ""

#. module: purchase_order_line_sequence
#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order__max_line_sequence
msgid "Max sequence in lines"
msgstr ""

#. module: purchase_order_line_sequence
#: model:ir.model,name:purchase_order_line_sequence.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: purchase_order_line_sequence
#: model:ir.model,name:purchase_order_line_sequence.model_purchase_order_line
msgid "Purchase Order Line"
msgstr ""

#. module: purchase_order_line_sequence
#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order_line__sequence2
msgid "Sequence"
msgstr ""

4 changes: 4 additions & 0 deletions purchase_order_line_sequence/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import purchase
from . import purchase_line
15 changes: 15 additions & 0 deletions purchase_order_line_sequence/models/invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2017 Camptocamp SA - Damien Crier, Alexandre Fayolle
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import models


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

def _set_additional_fields(self, invoice):
if self.purchase_line_id:
self.sequence = self.purchase_line_id.sequence
super(AccountInvoiceLine, self)._set_additional_fields(invoice)
95 changes: 95 additions & 0 deletions purchase_order_line_sequence/models/purchase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright 2017 Camptocamp SA - Damien Crier, Alexandre Fayolle
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

@api.depends("order_line")
def _compute_max_line_sequence(self):
"""Allow to know the highest sequence entered in purchase order lines.
Then we add 1 to this value for the next sequence which is given
to the context of the o2m field in the view. So when we create a new
purchase order line, the sequence is automatically max_sequence + 1
"""
for purchase in self:
purchase.max_line_sequence = (
max(purchase.mapped("order_line.sequence") or [0]) + 1
)

max_line_sequence = fields.Integer(
string="Max sequence in lines", compute="_compute_max_line_sequence"
)

def _create_picking(self):
res = super(PurchaseOrder, self)._create_picking()
for order in self:
if any(
[
ptype in ["product", "consu"]
for ptype in order.order_line.mapped("product_id.type")
]
):
pickings = order.picking_ids.filtered(
lambda x: x.state not in ("done", "cancel")
)
if pickings:
picking = pickings[0]
for move, line in zip(
sorted(picking.move_lines, key=lambda m: m.id), order.order_line
):
move.write({"sequence": line.sequence})
return res

def _reset_sequence(self):
for rec in self:
current_sequence = 1
for line in rec.order_line:
line.sequence = current_sequence
current_sequence += 1

def write(self, line_values):
res = super(PurchaseOrder, self).write(line_values)
self._reset_sequence()
return res

def copy(self, default=None):
return super(PurchaseOrder, self.with_context(keep_line_sequence=True)).copy(
default
)


class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"
_order = "sequence, id"

sequence = fields.Integer(
"Hidden Sequence",
help="Gives the sequence of the line when " "displaying the purchase order.",
default=9999,
)

sequence2 = fields.Integer(
"Sequence",
help="Displays the sequence of the line in " "the purchase order.",
related="sequence",
readonly=True,
)

def _prepare_stock_moves(self, picking):
res = super(PurchaseOrderLine, self)._prepare_stock_moves(picking)
for move, line in zip(res, self):
move.update(sequence=line.sequence)
return res

@api.model
def create(self, values):
line = super(PurchaseOrderLine, self).create(values)
# We do not reset the sequence when copying an entire purchase order
if not self.env.context.get("keep_line_sequence"):
line.order_id._reset_sequence()
return line
Loading