[IMP] sale_order_batch: apply pre-commit
This commit is contained in:
parent
9c46372caf
commit
e17935849c
13 changed files with 218 additions and 122 deletions
|
|
@ -1,3 +1,7 @@
|
|||
.. image:: https://odoo-community.org/readme-banner-image
|
||||
:target: https://odoo-community.org/get-involved?utm_source=readme
|
||||
:alt: Odoo Community Association
|
||||
|
||||
================
|
||||
Sale Order Batch
|
||||
================
|
||||
|
|
@ -13,12 +17,12 @@ Sale Order Batch
|
|||
.. |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-LGPL--3-blue.png
|
||||
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bakeupboys%2Fnfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bakeupboys/nfu/tree/16.0/sale_order_batch
|
||||
:alt: bakeupboys/nfu
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-madmooose%2Fodooapps-lightgray.png?logo=github
|
||||
:target: https://github.com/madmooose/odooapps/tree/16.0/sale_order_batch
|
||||
:alt: madmooose/odooapps
|
||||
|
||||
|badge1| |badge2| |badge3|
|
||||
|
||||
|
|
@ -49,10 +53,10 @@ Changelog
|
|||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/bakeupboys/nfu/issues>`_.
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/madmooose/odooapps/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/bakeupboys/nfu/issues/new?body=module:%20sale_order_batch%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/madmooose/odooapps/issues/new?body=module:%20sale_order_batch%0Aversion:%2016.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.
|
||||
|
||||
|
|
@ -63,6 +67,7 @@ Authors
|
|||
~~~~~~~
|
||||
|
||||
* BAKEUP
|
||||
* Niels Göttsch
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
|
@ -72,6 +77,6 @@ Contributors
|
|||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is part of the `bakeupboys/nfu <https://github.com/bakeupboys/nfu/tree/16.0/sale_order_batch>`_ project on GitHub.
|
||||
This module is part of the `madmooose/odooapps <https://github.com/madmooose/odooapps/tree/16.0/sale_order_batch>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "Sale Order Batch",
|
||||
"summary": "Group Sale Orders into a batch",
|
||||
"author": "BAKEUP",
|
||||
"website": "https://www.bakeup.org",
|
||||
"author": "BAKEUP,Niels Göttsch",
|
||||
"website": "https://ziemlichoptimal.de",
|
||||
"category": "Sale",
|
||||
"version": "16.0.2.3.1",
|
||||
"depends": ["sale", "product"],
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ from odoo.exceptions import UserError
|
|||
|
||||
from odoo.addons.sale.models.sale_order import INVOICE_STATUS
|
||||
|
||||
|
||||
STATES = [
|
||||
("open", "Open"),
|
||||
("in_progress", "In Progress"),
|
||||
|
|
@ -207,7 +206,8 @@ class SaleOrderBatch(models.Model):
|
|||
self.write({"state": "cancel"})
|
||||
|
||||
def _show_cancel_wizard(self):
|
||||
"""Decide whether the sale.order.batch.cancel wizard should be shown to cancel specified orders.
|
||||
"""Decide whether the sale.order.batch.cancel wizard should be shown to cancel
|
||||
specified orders.
|
||||
|
||||
:return: True if there is any non-draft order in the given orders
|
||||
:rtype: bool
|
||||
|
|
@ -250,7 +250,8 @@ class SaleOrderBatchCancelWizard(models.TransientModel):
|
|||
if not_draft_orders:
|
||||
raise UserError(
|
||||
_(
|
||||
"You can only cancel batches where all sale orders are in draft state."
|
||||
"You can only cancel batches where all sale orders are in "
|
||||
"draft state."
|
||||
)
|
||||
)
|
||||
# use _action_cancel to skip the wizzard
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class SaleOrderLine(models.Model):
|
|||
batch_product_id = fields.Many2one("sale.order.batch.product", ondelete="restrict")
|
||||
|
||||
def _link_batch_product(self):
|
||||
lines_with_batch = self.filtered(lambda l: l.batch_id)
|
||||
lines_with_batch = self.filtered(lambda line: line.batch_id)
|
||||
for line in lines_with_batch:
|
||||
batch_id = line.batch_id
|
||||
batch_product = self.env["sale.order.batch.product"].search(
|
||||
|
|
@ -25,17 +25,17 @@ class SaleOrderLine(models.Model):
|
|||
line.batch_product_id = batch_product
|
||||
|
||||
def _unlink_batch_product(self):
|
||||
lines_to_unlink = self.filtered(lambda l: l.batch_product_id)
|
||||
lines_to_unlink = self.filtered(lambda line: line.batch_product_id)
|
||||
batch_products = lines_to_unlink.mapped("batch_product_id")
|
||||
lines_to_unlink.update({"batch_product_id": False})
|
||||
batch_products.filtered(lambda p: len(p.sale_order_line_ids) == 0).unlink()
|
||||
|
||||
def _update_batch_product(self):
|
||||
lines_with_batch = self.filtered(lambda l: l.batch_id)
|
||||
lines_with_batch = self.filtered(lambda line: line.batch_id)
|
||||
lines_without_batch = self - lines_with_batch
|
||||
lines_with_batch.filtered(
|
||||
lambda l: l.batch_product_id
|
||||
and l.batch_product_id.product_id != l.product_id
|
||||
lambda line: line.batch_product_id
|
||||
and line.batch_product_id.product_id != line.product_id
|
||||
)._unlink_batch_product()
|
||||
lines_with_batch._link_batch_product()
|
||||
lines_without_batch._unlink_batch_product()
|
||||
|
|
|
|||
3
sale_order_batch/pyproject.toml
Normal file
3
sale_order_batch/pyproject.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[build-system]
|
||||
requires = ["whool"]
|
||||
build-backend = "whool.buildapi"
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
|
||||
<title>Sale Order Batch</title>
|
||||
<title>README.rst</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
|
|
@ -360,16 +360,21 @@ ul.auto-toc {
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="sale-order-batch">
|
||||
<h1 class="title">Sale Order Batch</h1>
|
||||
<div class="document">
|
||||
|
||||
|
||||
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
|
||||
</a>
|
||||
<div class="section" id="sale-order-batch">
|
||||
<h1>Sale Order Batch</h1>
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:6686f0672ede8093b17d5d7b165f72f8e49341c7849f9e0d5a162e350fc36d71
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bakeupboys/nfu/tree/16.0/sale_order_batch"><img alt="bakeupboys/nfu" src="https://img.shields.io/badge/github-bakeupboys%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/madmooose/odooapps/tree/16.0/sale_order_batch"><img alt="madmooose/odooapps" src="https://img.shields.io/badge/github-madmooose%2Fodooapps-lightgray.png?logo=github" /></a></p>
|
||||
<p>This module adds the possibility to group Sale orders into batches. Attributes of a Sale Order Batch will be written to all
|
||||
Sale Order. Wenn attached to a batch they can be processed together. On the other hand they cannot be proccesed individual
|
||||
anymore as log as they are part of a batch. Only Sale Orders in state Qutotation or Quotation Send can be attached to a batch.</p>
|
||||
|
|
@ -387,7 +392,7 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation
|
|||
</ul>
|
||||
</div>
|
||||
<div class="section" id="changelog">
|
||||
<h1><a class="toc-backref" href="#toc-entry-1">Changelog</a></h1>
|
||||
<h2><a class="toc-backref" href="#toc-entry-1">Changelog</a></h2>
|
||||
<ul class="simple">
|
||||
<li>16.0.0.0.1: Initial module.</li>
|
||||
<li>16.0.0.1: Add Multi Company ability</li>
|
||||
|
|
@ -403,33 +408,35 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation
|
|||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bakeupboys/nfu/issues">GitHub Issues</a>.
|
||||
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/madmooose/odooapps/issues">GitHub Issues</a>.
|
||||
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
|
||||
<a class="reference external" href="https://github.com/bakeupboys/nfu/issues/new?body=module:%20sale_order_batch%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/madmooose/odooapps/issues/new?body=module:%20sale_order_batch%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
|
||||
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
|
||||
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
|
||||
<ul class="simple">
|
||||
<li>BAKEUP</li>
|
||||
<li>Niels Göttsch</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
|
||||
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
|
||||
<ul class="simple">
|
||||
<li>Niels Göttsch <<a class="reference external" href="mailto:niels@ziemlichoptimal.de">niels@ziemlichoptimal.de</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/bakeupboys/nfu/tree/16.0/sale_order_batch">bakeupboys/nfu</a> project on GitHub.</p>
|
||||
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/madmooose/odooapps/tree/16.0/sale_order_batch">madmooose/odooapps</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@
|
|||
</group>
|
||||
<notebook>
|
||||
<page string="Sale Order Lines" name="order_line">
|
||||
<field name="sale_order_line_ids" widget="section_and_note_one2many">
|
||||
<field
|
||||
name="sale_order_line_ids"
|
||||
widget="section_and_note_one2many"
|
||||
>
|
||||
<tree editable="bottom" create="0">
|
||||
<field name="company_id" invisible="1" />
|
||||
<field name="sequence" widget="handle" />
|
||||
|
|
|
|||
|
|
@ -7,8 +7,17 @@
|
|||
<tree>
|
||||
<field name="name" />
|
||||
<field name="date_order" />
|
||||
<field name="company_id" groups="base.group_multi_company" optional="show" readonly="1"/>
|
||||
<field name="company_id" groups="!base.group_multi_company" invisible="1"/>
|
||||
<field
|
||||
name="company_id"
|
||||
groups="base.group_multi_company"
|
||||
optional="show"
|
||||
readonly="1"
|
||||
/>
|
||||
<field
|
||||
name="company_id"
|
||||
groups="!base.group_multi_company"
|
||||
invisible="1"
|
||||
/>
|
||||
<field name="sale_order_ids" widget="many2many_tags" />
|
||||
<field
|
||||
name="state"
|
||||
|
|
@ -36,8 +45,17 @@
|
|||
<tree>
|
||||
<field name="name" />
|
||||
<field name="date_order" />
|
||||
<field name="company_id" groups="base.group_multi_company" optional="show" readonly="1"/>
|
||||
<field name="company_id" groups="!base.group_multi_company" invisible="1"/>
|
||||
<field
|
||||
name="company_id"
|
||||
groups="base.group_multi_company"
|
||||
optional="show"
|
||||
readonly="1"
|
||||
/>
|
||||
<field
|
||||
name="company_id"
|
||||
groups="!base.group_multi_company"
|
||||
invisible="1"
|
||||
/>
|
||||
<field name="sale_order_ids" widget="many2many_tags" />
|
||||
<field
|
||||
name="state"
|
||||
|
|
@ -131,7 +149,11 @@
|
|||
icon="fa-pencil-square-o"
|
||||
attrs="{'invisible': [('sale_order_count', '=', 0)]}"
|
||||
>
|
||||
<field string="Sale Orders" name="sale_order_count" widget="statinfo"/>
|
||||
<field
|
||||
string="Sale Orders"
|
||||
name="sale_order_count"
|
||||
widget="statinfo"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
class="oe_stat_button"
|
||||
|
|
@ -140,7 +162,11 @@
|
|||
icon="fa-cart-plus"
|
||||
attrs="{'invisible': [('product_count', '=', 0)]}"
|
||||
>
|
||||
<field string="Products" name="product_count" widget="statinfo"/>
|
||||
<field
|
||||
string="Products"
|
||||
name="product_count"
|
||||
widget="statinfo"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
name="action_view_invoice"
|
||||
|
|
@ -149,7 +175,11 @@
|
|||
icon="fa-pencil-square-o"
|
||||
attrs="{'invisible': [('invoice_count', '=', 0)]}"
|
||||
>
|
||||
<field name="invoice_count" widget="statinfo" string="Invoices"/>
|
||||
<field
|
||||
name="invoice_count"
|
||||
widget="statinfo"
|
||||
string="Invoices"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<h1>
|
||||
|
|
@ -161,8 +191,16 @@
|
|||
</group>
|
||||
<group>
|
||||
<field name="date_order" />
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
<field name="company_id" invisible="1" groups="!base.group_multi_company"/>
|
||||
<field
|
||||
name="company_id"
|
||||
options="{'no_create': True}"
|
||||
groups="base.group_multi_company"
|
||||
/>
|
||||
<field
|
||||
name="company_id"
|
||||
invisible="1"
|
||||
groups="!base.group_multi_company"
|
||||
/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
|
|
@ -195,7 +233,10 @@
|
|||
</field>
|
||||
</page>
|
||||
<page string="Sale Order Lines" name="order_line">
|
||||
<field name="sale_order_line_ids" widget="section_and_note_one2many">
|
||||
<field
|
||||
name="sale_order_line_ids"
|
||||
widget="section_and_note_one2many"
|
||||
>
|
||||
<tree create="0" editable="bottom">
|
||||
<field name="sequence" widget="handle" />
|
||||
<field name="order_id" />
|
||||
|
|
@ -217,8 +258,14 @@
|
|||
<field name="product_id" />
|
||||
<field name="product_uom_qty" />
|
||||
<field name="lst_price" />
|
||||
<field name="product_packaging_qty" groups="product.group_stock_packaging"/>
|
||||
<field name="product_packaging_id" groups="product.group_stock_packaging"/>
|
||||
<field
|
||||
name="product_packaging_qty"
|
||||
groups="product.group_stock_packaging"
|
||||
/>
|
||||
<field
|
||||
name="product_packaging_id"
|
||||
groups="product.group_stock_packaging"
|
||||
/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
|
@ -237,9 +284,21 @@
|
|||
<field name="model">sale.order.batch</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<filter string="Active" name="filter_batch_open" domain="[('state', 'in', ['open', 'in_progress'])]"/>
|
||||
<filter string="Finished" name="filter_batch_finished" domain="[('state', '=', 'closed')]"/>
|
||||
<filter string="Cancelled" name="filter_batch_cancel" domain="[('state', '=', 'cancel')]"/>
|
||||
<filter
|
||||
string="Active"
|
||||
name="filter_batch_open"
|
||||
domain="[('state', 'in', ['open', 'in_progress'])]"
|
||||
/>
|
||||
<filter
|
||||
string="Finished"
|
||||
name="filter_batch_finished"
|
||||
domain="[('state', '=', 'closed')]"
|
||||
/>
|
||||
<filter
|
||||
string="Cancelled"
|
||||
name="filter_batch_cancel"
|
||||
domain="[('state', '=', 'cancel')]"
|
||||
/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
|
|
@ -23,15 +23,24 @@
|
|||
icon="fa-tasks"
|
||||
attrs="{'invisible': [('batch_id', '=', False)]}"
|
||||
>
|
||||
<field name="batch_id" attrs="{'readonly': True}"/>
|
||||
<field
|
||||
name="batch_id"
|
||||
attrs="{'readonly': True}"
|
||||
/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='action_confirm']" position="attributes">
|
||||
<xpath
|
||||
expr="//button[@name='action_confirm']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute
|
||||
name="attrs"
|
||||
>{'invisible': ['|',('batch_id','!=',False),('state', 'not in', ['sent'])]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='action_confirm'][2]" position="attributes">
|
||||
<xpath
|
||||
expr="//button[@name='action_confirm'][2]"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute
|
||||
name="attrs"
|
||||
>{'invisible': ['|',('batch_id','!=',False),('state', 'not in', ['draft'])]}</attribute>
|
||||
|
|
@ -49,7 +58,11 @@
|
|||
<field name="arch" type="xml">
|
||||
<xpath expr="//tree" position="inside">
|
||||
<header>
|
||||
<button type="object" name="action_add_to_batch" string="Add to Batch"/>
|
||||
<button
|
||||
type="object"
|
||||
name="action_add_to_batch"
|
||||
string="Add to Batch"
|
||||
/>
|
||||
</header>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
|
|
|
|||
|
|
@ -15,7 +15,12 @@
|
|||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Cancel" name="action_cancel" type="object" class="btn-primary mx-1"/>
|
||||
<button
|
||||
string="Cancel"
|
||||
name="action_cancel"
|
||||
type="object"
|
||||
class="btn-primary mx-1"
|
||||
/>
|
||||
<button string="Discard" class="btn-secondary" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Reference in a new issue