Skip to content

Commit

Permalink
IMP ui and refactor action
Browse files Browse the repository at this point in the history
  • Loading branch information
bealdav authored and Pierrick Brun committed Dec 17, 2020
1 parent dede880 commit 7fe3072
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 51 deletions.
37 changes: 12 additions & 25 deletions base_product_mass_addition/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@ Base Product Mass Addition
.. |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%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/12.0/base_product_mass_addition
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-12-0/product-attribute-12-0-base_product_mass_addition
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/135/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
.. |badge3| image:: https://img.shields.io/badge/github-oca%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/oca/product-attribute/tree/12.0/base_product_mass_addition
:alt: oca/product-attribute

|badge1| |badge2| |badge3|

This module is abstract and can't be used as is.

Expand Down Expand Up @@ -55,10 +49,10 @@ on sale.order or on stock.picking.batch for instance.
Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
Bugs are tracked on `GitHub Issues <https://github.com/oca/product-attribute/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/product-attribute/issues/new?body=module:%20base_product_mass_addition%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/oca/product-attribute/issues/new?body=module:%20base_product_mass_addition%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.

Expand All @@ -73,23 +67,16 @@ Authors
Contributors
~~~~~~~~~~~~

Akretion

* Sébastien BEAU <[email protected]>
* Mourad EL HADJ MIMOUNE <[email protected]>
* Pierrick Brun <[email protected]>
* David Béal <[email protected]>

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/product-attribute <https://github.com/OCA/product-attribute/tree/12.0/base_product_mass_addition>`_ project on GitHub.
This module is part of the `oca/product-attribute <https://github.com/oca/product-attribute/tree/12.0/base_product_mass_addition>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
You are welcome to contribute.
14 changes: 13 additions & 1 deletion base_product_mass_addition/models/product_mass_addition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


from odoo import models
from odoo import models, api
from odoo.tests.common import Form


Expand All @@ -12,6 +12,18 @@ class ProductMassAddition(models.AbstractModel):
_description = 'inherit this to add a mass product addition function\
to your model'

@api.model
def _common_action_keys(self):
""" Call it in your own child module
"""
return {
'type': 'ir.actions.act_window',
'res_model': 'product.product',
'target': 'current',
'context': {'parent_id': self.id, 'parent_model': self._name},
'view_mode': 'tree',
}

def _prepare_quick_line(self, product):
res = self._get_quick_line_qty_vals(product)
res.update({'product_id': product.id})
Expand Down
21 changes: 9 additions & 12 deletions base_product_mass_addition/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@ def _compute_process_qty(self):
return

@api.multi
def button_return_parent(self):
def button_quick_open_product(self):
self.ensure_one()
parent_id = self.env.context.get('parent_id')
parent_model = self.env.context.get('parent_model')
if parent_id:
parent = self.env[parent_model].browse(parent_id)
return {
'name': parent.display_name,
'type': 'ir.actions.act_window',
'res_model': parent_model,
'view_mode': 'form',
'res_id': parent_id,
}
return {
'name': self.display_name,
'type': 'ir.actions.act_window',
'res_model': self._name,
'view_mode': 'form',
'res_id': self.id,
'target': 'current',
}
3 changes: 3 additions & 0 deletions base_product_mass_addition/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Akretion

* Sébastien BEAU <[email protected]>
* Mourad EL HADJ MIMOUNE <[email protected]>
* Pierrick Brun <[email protected]>
* David Béal <[email protected]>
17 changes: 7 additions & 10 deletions base_product_mass_addition/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Base Product Mass Addition</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/product-attribute/tree/12.0/base_product_mass_addition"><img alt="OCA/product-attribute" src="https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/product-attribute-12-0/product-attribute-12-0-base_product_mass_addition"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/135/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/oca/product-attribute/tree/12.0/base_product_mass_addition"><img alt="oca/product-attribute" src="https://img.shields.io/badge/github-oca%2Fproduct--attribute-lightgray.png?logo=github" /></a></p>
<p>This module is abstract and can’t be used as is.</p>
<p>It provides functions in order to show a product grid from another model.
You can then add products and quantities in batch to the model you are working with.</p>
Expand Down Expand Up @@ -404,10 +404,10 @@ <h1><a class="toc-backref" href="#id1">Known issues / Roadmap</a></h1>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/product-attribute/issues">GitHub Issues</a>.
<p>Bugs are tracked on <a class="reference external" href="https://github.com/oca/product-attribute/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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/product-attribute/issues/new?body=module:%20base_product_mass_addition%0Aversion:%2012.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/oca/product-attribute/issues/new?body=module:%20base_product_mass_addition%0Aversion:%2012.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">
Expand All @@ -420,21 +420,18 @@ <h2><a class="toc-backref" href="#id4">Authors</a></h2>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<p>Akretion</p>
<ul class="simple">
<li>Sébastien BEAU &lt;<a class="reference external" href="mailto:sebastien.beau&#64;akretion.com">sebastien.beau&#64;akretion.com</a>&gt;</li>
<li>Mourad EL HADJ MIMOUNE &lt;<a class="reference external" href="mailto:mourad.elhadj.mimoune&#64;akretion.com">mourad.elhadj.mimoune&#64;akretion.com</a>&gt;</li>
<li>Pierrick Brun &lt;<a class="reference external" href="mailto:pierrick.brun&#64;akretion.com">pierrick.brun&#64;akretion.com</a>&gt;</li>
<li>David Béal &lt;<a class="reference external" href="mailto:david.beal&#64;akretion.com">david.beal&#64;akretion.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-attribute/tree/12.0/base_product_mass_addition">OCA/product-attribute</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/oca/product-attribute/tree/12.0/base_product_mass_addition">oca/product-attribute</a> project on GitHub.</p>
<p>You are welcome to contribute.</p>
</div>
</div>
</div>
Expand Down
5 changes: 2 additions & 3 deletions base_product_mass_addition/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
<tree string="Products" create="0" editable="top">
<field name="lst_price" readonly="1"/>
<field name="categ_id" readonly="1"/>
<field name="default_code" readonly="1"/>
<field name="name" readonly="1"/>
<field name="display_name" readonly="1"/>
<field name="qty_to_process"/>
<field name="incoming_qty"/>
<field name="qty_available"/>
<button name="button_return_parent" string="Return" type="object"/>
<button name="button_quick_open_product" string="Open" type="object"/>
</tree>
</field>
</record>
Expand Down

0 comments on commit 7fe3072

Please sign in to comment.