Skip to content

Commit

Permalink
[IMP] sale_product_set module
Browse files Browse the repository at this point in the history
  • Loading branch information
AdriaGForgeFlow authored and MiquelRForgeFlow committed Jul 30, 2019
1 parent 5233f06 commit fbf7c63
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions sale_product_set/README.rst
Expand Up @@ -50,6 +50,7 @@ To use this module, you need to:
* Define a *product set* as sale manager:
- choose products
- for each products, define a quantity.
- for each products (if Discounts setting is active), define a discount or leave default value
- Sort *set* lines, this order will be the default when added into the
quotation

Expand Down Expand Up @@ -95,6 +96,7 @@ Contributors
* Denis Leemann <denis.leemann@camptocamp.com>
* Simone Orsi <simone.orsi@camptocamp.com>
* Souheil Bejaoui <souheil.bejaoui@acsone.eu>
* Adria Gil Sorribes <adria.gil@eficent.com>

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 2 additions & 0 deletions sale_product_set/demo/product_set_line.xml
Expand Up @@ -4,6 +4,7 @@
<field name="product_set_id" ref="product_set_i5_computer"/>
<field name="product_id" ref="product.product_product_5"/>
<field name="quantity">1</field>
<field name="discount">25</field>
<field name="sequence">30</field>
</record>
<record id="product_set_line_computer_3" model="product.set.line">
Expand All @@ -23,6 +24,7 @@
<field name="product_set_id" ref="product_set_services"/>
<field name="product_id" ref="product.product_product_2"/>
<field name="quantity">1</field>
<field name="discount">50</field>
</record>
<record id="product_set_line_services_2" model="product.set.line">
<field name="product_set_id" ref="product_set_services"/>
Expand Down
5 changes: 5 additions & 0 deletions sale_product_set/models/product_set_line.py
Expand Up @@ -33,3 +33,8 @@ class ProductSetLine(models.Model):
required=True,
default=0,
)
discount = fields.Float(
string='Discount (%)',
digits=dp.get_precision('Discount'),
default=0.0
)
1 change: 1 addition & 0 deletions sale_product_set/readme/CONTRIBUTORS.rst
Expand Up @@ -3,3 +3,4 @@
* Denis Leemann <denis.leemann@camptocamp.com>
* Simone Orsi <simone.orsi@camptocamp.com>
* Souheil Bejaoui <souheil.bejaoui@acsone.eu>
* Adria Gil Sorribes <adria.gil@eficent.com>
2 changes: 1 addition & 1 deletion sale_product_set/readme/DESCRIPTION.rst
Expand Up @@ -8,4 +8,4 @@ After a *product set* is added to the sale order, each line can be updated or
removed as any other sale order lines.

This differs from packing products as you don't follow *product set*
are not linked to sale order lines once they are added.
are not linked to sale order lines once they are added.
3 changes: 2 additions & 1 deletion sale_product_set/readme/USAGE.rst
Expand Up @@ -3,6 +3,7 @@ To use this module, you need to:
* Define a *product set* as sale manager:
- choose products
- for each products, define a quantity.
- for each products (if Discounts setting is active), define a discount or leave default value
- Sort *set* lines, this order will be the default when added into the
quotation

Expand All @@ -20,4 +21,4 @@ To use this module, you need to:
* Then you can remove or update added lines as any other sale order lines.

.. image:: /sale_product_set/static/description/sale_order.png
:alt: Sale order
:alt: Sale order
Binary file modified sale_product_set/static/description/add_set.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions sale_product_set/static/description/index.html
Expand Up @@ -398,6 +398,7 @@ <h1><a class="toc-backref" href="#id1">Usage</a></h1>
<dd><ul class="first last">
<li>choose products</li>
<li>for each products, define a quantity.</li>
<li>for each products (if Discounts setting is active), define a discount or leave default value</li>
<li>Sort <em>set</em> lines, this order will be the default when added into the
quotation</li>
</ul>
Expand Down Expand Up @@ -442,6 +443,7 @@ <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<li>Denis Leemann &lt;<a class="reference external" href="mailto:denis.leemann&#64;camptocamp.com">denis.leemann&#64;camptocamp.com</a>&gt;</li>
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
<li>Souheil Bejaoui &lt;<a class="reference external" href="mailto:souheil.bejaoui&#64;acsone.eu">souheil.bejaoui&#64;acsone.eu</a>&gt;</li>
<li>Adria Gil Sorribes &lt;<a class="reference external" href="mailto:adria.gil&#64;eficent.com">adria.gil&#64;eficent.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Binary file modified sale_product_set/static/description/product_set.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sale_product_set/static/description/sale_order.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions sale_product_set/tests/test_product_set.py
Expand Up @@ -29,10 +29,11 @@ def test_add_set(self):
so_set.add_set()
# checking our sale order
self.assertEqual(len(so.order_line), count_lines + 3)
# untaxed_amount + ((147*1)+(2100*1)+(85*2)) * 2
self.assertEqual(so.amount_untaxed, untaxed_amount + 4834.0)
# untaxed_amount + ((147*1*0.75)+(2100*1)+(85*2)) * 2
# 0.75 due to a 25% discount on Custom Computer (kit) product
self.assertEqual(so.amount_untaxed, untaxed_amount + 4760.5)
self.assertEqual(so.amount_tax, tax_amount + 0) # without tax
self.assertEqual(so.amount_total, total_amount + 4834.0)
self.assertEqual(so.amount_total, total_amount + 4760.5)
sequence = {}
for line in so.order_line:
sequence[line.product_id.id] = line.sequence
Expand Down
1 change: 1 addition & 0 deletions sale_product_set/views/product_set.xml
Expand Up @@ -31,6 +31,7 @@
<field name="sequence" widget="handle"/>
<field name="product_id"/>
<field name="quantity"/>
<field name="discount" groups="sale.group_discount_per_so_line"/>
</tree>
</field>
</group>
Expand Down
1 change: 1 addition & 0 deletions sale_product_set/wizard/product_set_add.py
Expand Up @@ -45,6 +45,7 @@ def prepare_sale_order_line_data(self, sale_order_id, set_line,
'product_uom_qty': set_line.quantity * self.quantity,
'product_uom': set_line.product_id.uom_id.id,
'sequence': max_sequence + set_line.sequence,
'discount': set_line.discount,
})
sale_line.product_id_change()
line_values = sale_line._convert_to_write(sale_line._cache)
Expand Down

0 comments on commit fbf7c63

Please sign in to comment.