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

[16.0][MIG] recurring_consignment_purchase: Migration to 16.0 (from 12.0) #146

Draft
wants to merge 23 commits into
base: 16.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b27912a
[MIG] recurring_consignment: Migration to 12.0
legalsylvain Dec 4, 2019
191af60
[UPD] README.rst
github-grap-bot May 24, 2020
f9158c8
recurring_consignment_purchase 12.0.1.0.1
github-grap-bot May 24, 2020
2102efe
[FIX] recurring_consignment_purchase: bad dependency
legalsylvain Dec 10, 2020
213be99
recurring_consignment_purchase 12.0.1.0.2
github-grap-bot Dec 11, 2020
3f42a15
[IMP] Hide invoice button
quentinDupont Feb 8, 2021
49b213e
recurring_consignment_purchase 12.0.1.0.3
github-grap-bot Feb 15, 2021
0a677ae
[REF] add pre-commit
legalsylvain Feb 16, 2021
7e94043
[BLACK]
legalsylvain Feb 16, 2021
1cb8350
recurring_consignment_purchase 12.0.1.1.0
github-grap-bot Feb 22, 2021
6f54ad6
[IMP] Purchase state
quentinDupont Feb 18, 2021
a89f866
recurring_consignment_purchase 12.0.1.1.1
github-grap-bot Apr 13, 2021
6000ee8
[FIX] recurring_consignment_murchase : make button_validate working …
legalsylvain May 26, 2021
f9be874
recurring_consignment_purchase 12.0.1.1.2
github-grap-bot Jun 11, 2021
c86776d
[12.0][REF] uniformize website in __manifest__.py + add pre-commit check
legalsylvain Oct 25, 2021
e22fed5
recurring_consignment_purchase 12.0.1.1.3
github-grap-bot Oct 25, 2021
9e55bfb
[FR] recurring_consignment_* : update fr translation
legalsylvain Mar 6, 2022
bb1df6e
recurring_consignment_purchase 12.0.1.1.4
github-grap-bot Mar 8, 2022
e52de65
[REF] recurring_consignment_* : Single VAT to make consignment invoices
legalsylvain Feb 8, 2023
1ae8677
[UPD] README.rst
github-grap-bot Oct 2, 2023
0312389
[BOT] post-merge updates
github-grap-bot Nov 21, 2023
6a3e9a0
[IMP] recurring_consignment_purchase: pre-commit stuff
legalsylvain May 20, 2024
a390dce
[MIG] recurring_consignment_purchase: Migration to 16.0 (from 12.0)
legalsylvain May 20, 2024
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
66 changes: 66 additions & 0 deletions recurring_consignment_purchase/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
==================================
Recurring Consignment for Purchase
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8555c6f4742e94e387cd6aea7e1f96099c592d885196dc85785172c4465c097d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-grap%2Fgrap--odoo--business-lightgray.png?logo=github
:target: https://github.com/grap/grap-odoo-business/tree/12.0/recurring_consignment_purchase
:alt: grap/grap-odoo-business

|badge1| |badge2| |badge3|

This module is a glue module between ``recurring_consignment`` and
``purchase`` module.

* it will block the creation of invoices, from purchase order done for consignors.

* It will prevent to change consignor on a product, once the product has been purchased.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/grap/grap-odoo-business/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/grap/grap-odoo-business/issues/new?body=module:%20recurring_consignment_purchase%0Aversion:%2012.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
~~~~~~~

* GRAP

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

* Julien WESTE
* Sylvain LE GAL (https://www.twitter.com/legalsylvain)

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

This module is part of the `grap/grap-odoo-business <https://github.com/grap/grap-odoo-business/tree/12.0/recurring_consignment_purchase>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions recurring_consignment_purchase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions recurring_consignment_purchase/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2014 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Recurring Consignment for Purchase",
"version": "16.0.1.0.0",
"summary": "Glue module for Recurring Consignment and Purchase modules",
"category": "Sale",
"author": "GRAP",
"website": "https://github.com/grap/grap-odoo-business",
"license": "AGPL-3",
"depends": [
"recurring_consignment",
"purchase",
"stock",
],
"data": ["views/view_purchase_order.xml"],
"installable": True,
"auto_install": True,
}
60 changes: 60 additions & 0 deletions recurring_consignment_purchase/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * recurring_consignment_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-06 22:51+0000\n"
"PO-Revision-Date: 2022-03-06 22:51+0000\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: recurring_consignment_purchase
#: model:ir.model.fields,field_description:recurring_consignment_purchase.field_purchase_order__consignment_trade
msgid "Consignment Trade"
msgstr "Transaction de dépôt vente"

#. module: recurring_consignment_purchase
#: model:ir.model,name:recurring_consignment_purchase.model_product_template
msgid "Product Template"
msgstr "Modèle d'article"

#. module: recurring_consignment_purchase
#: model:ir.model,name:recurring_consignment_purchase.model_purchase_order
msgid "Purchase Order"
msgstr "Commande fournisseur"

#. module: recurring_consignment_purchase
#: model:ir.model,name:recurring_consignment_purchase.model_stock_picking
msgid "Transfer"
msgstr "Transfert"

#. module: recurring_consignment_purchase
#: code:addons/recurring_consignment_purchase/models/product_template.py:27
#, python-format
msgid "You can not change the value of the field 'Consignor' because the product is associated to one or more Purchase Order Lines. You should disable the product and create a new one."
msgstr "Vous ne pouvez pas changer la valeur du champ 'Dépôt-vendeur' car le produit est associé à une ou plusieurs lignes de commandes d'achats. Vous devez désactiver le produit, et en créer un nouveau."

#. module: recurring_consignment_purchase
#: code:addons/recurring_consignment_purchase/models/purchase_order.py:22
#, python-format
msgid "You can not make invoices for purchase order(s) %s because there are associated to consignor(s)."
msgstr "Vous ne pouvez pas faire de factures pour le(s) bon(s) de commande %s car ils sont associés à un dépôt vendeur."

#. module: recurring_consignment_purchase
#: code:addons/recurring_consignment_purchase/models/purchase_order_line.py:21
#, python-format
msgid "You can not purchase consigned products to a supplier that is not flagged as consignor."
msgstr "Vous ne pouvez pas acheter de produit de dépôt vendeur à un fournisseur, si celui ci n'est pas un dépôt vendeur."

#. module: recurring_consignment_purchase
#: code:addons/recurring_consignment_purchase/models/purchase_order_line.py:17
#, python-format
msgid "You can only purchase consigned products to consignor."
msgstr "Vous pouvez seulement acheter des produits de dépôt-vente à un dépôt vendeur."
4 changes: 4 additions & 0 deletions recurring_consignment_purchase/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import product_template
from . import purchase_order
from . import purchase_order_line
from . import stock_picking
32 changes: 32 additions & 0 deletions recurring_consignment_purchase/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, api, models
from odoo.exceptions import UserError


class ProductTemplate(models.Model):
_inherit = "product.template"

def _check_consignor_changes(self, vals):
super()._check_consignor_changes(vals)
PurchaseOrderLine = self.env["purchase.order.line"]
if vals.get("consignor_partner_id", False):
for template in self:
product_ids = template.product_variant_ids.ids
if template.consignor_partner_id.id != vals.get(
"consignor_partner_id", False
):
order_lines = PurchaseOrderLine.search(
[("product_id", "in", product_ids)]
)
if len(order_lines):
raise UserError(
_(
"You can not change the value of the field"
" 'Consignor' because the product is associated"
" to one or more Purchase Order Lines. You should"
" disable the product and create a new one."
)
)
28 changes: 28 additions & 0 deletions recurring_consignment_purchase/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (C) 2015 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# @author: Quentin DUPONT (https://twitter.com/pondupont)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, api, fields, models
from odoo.exceptions import UserError


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

consignment_trade = fields.Boolean(
string="Consignment Trade", related="partner_id.is_consignor"
)

def action_view_invoice(self):
orders = self.filtered(lambda x: x.consignment_trade)
if orders:
raise UserError(
_(
"You can not make invoices for purchase order(s) %s"
" because there are associated to consignor(s)."
)
% (", ".join([x.name for x in orders]))
)
res = super().action_view_invoice()
return res
25 changes: 25 additions & 0 deletions recurring_consignment_purchase/models/purchase_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, api, models
from odoo.exceptions import UserError


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

@api.constrains("product_id")
def _check_order_line_recurring_consignment(self):
for line in self:
if line.order_id.consignment_trade and not line.product_id.is_consignment:
raise UserError(
_("You can only purchase consigned products to consignor.")
)
if not line.order_id.consignment_trade and line.product_id.is_consignment:
raise UserError(
_(
"You can not purchase consigned products to a supplier"
" that is not flagged as consignor."
)
)
17 changes: 17 additions & 0 deletions recurring_consignment_purchase/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop)
# @author: Quentin DUPONT <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class Picking(models.Model):
_inherit = "stock.picking"

def button_validate(self):
res = super().button_validate()
for picking in self:
if picking.purchase_id and picking.purchase_id.consignment_trade:
picking.purchase_id.button_done()
picking.purchase_id.invoice_status = "no"
return res
2 changes: 2 additions & 0 deletions recurring_consignment_purchase/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Julien WESTE
* Sylvain LE GAL (https://www.twitter.com/legalsylvain)
6 changes: 6 additions & 0 deletions recurring_consignment_purchase/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module is a glue module between ``recurring_consignment`` and
``purchase`` module.

* it will block the creation of invoices, from purchase order done for consignors.

* It will prevent to change consignor on a product, once the product has been purchased.
37 changes: 37 additions & 0 deletions recurring_consignment_purchase/views/view_purchase_order.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2021 - Today: GRAP (http://www.grap.coop)
@author Quentin DUPONT <[email protected]>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<record id="view_recurring_purchase_order_form" model="ir.ui.view">
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="consignment_trade" invisible="1"/>
</field>
<!-- make priority bigger to make sure that this XPATH is used after the one
that adds the button -->
<!-- button oe_highlight -->
<xpath expr='//button[@name="action_view_invoice"][1]' position='attributes'>
<attribute name="attrs">{'invisible':
['|', ('state', 'not in', ('purchase', 'done')),
'|', ('invoice_status', 'in', ('no', 'invoiced')),
('consignment_trade', '=', True)]}</attribute>
</xpath>
<!-- button pas oe_highlight -->
<xpath expr='//button[@name="action_view_invoice"][2]' position='attributes'>
<attribute name="attrs">
{'invisible':
['|', ('state', 'not in', ('purchase', 'done')),
'|', ('invoice_status', 'not in', ('no', 'invoiced')),
'|', ('order_line', '=', []),
('consignment_trade', '=', True)]}</attribute>
</xpath>
</field>
</record>

</odoo>
6 changes: 6 additions & 0 deletions setup/recurring_consignment_purchase/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading