Skip to content

Commit

Permalink
[MIG] stock_voucher: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
augusto-weiss committed Jan 29, 2024
1 parent e5ef3bb commit 7328846
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 69 deletions.
6 changes: 3 additions & 3 deletions stock_voucher/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Stock Voucher',
'version': "16.0.1.1.0",
'version': "17.0.1.0.0",
'category': 'Warehouse Management',
'sequence': 14,
'summary': '',
Expand All @@ -30,7 +30,7 @@
],
'depends': [
'sale_stock',
'web_ir_actions_act_multi',
'web_ir_actions_act_multi'
],
'data': [
'security/stock_voucher_security.xml',
Expand All @@ -47,7 +47,7 @@
],
'demo': [
],
'installable': False,
'installable': True,
'auto_install': False,
'application': False,
}
10 changes: 7 additions & 3 deletions stock_voucher/models/stock_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ class StockBook(models.Model):
'ir.sequence',
'Stock Voucher Sequence',
domain=[('code', '=', 'stock.voucher')],
context="{'default_code': 'stock.voucher', 'default_name': name, "
"'default_prefix': '000X-', 'default_padding': 8, "
"'default_implementation': 'no_gap',}",
context={
'default_code': 'stock.voucher',
'default_name': name,
'default_prefix': '000X-',
'default_padding': 8,
'default_implementation': 'no_gap'
},
required=True,
)
lines_per_voucher = fields.Integer(
Expand Down
15 changes: 8 additions & 7 deletions stock_voucher/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class StockPicking(models.Model):
'Voucher Book',
copy=False,
ondelete='restrict',
check_company=True
)
vouchers = fields.Char(
compute='_compute_vouchers',
Expand Down Expand Up @@ -143,7 +144,7 @@ def button_validate(self):
@api.depends(
'automatic_declare_value',
'move_ids.state',
'move_ids.quantity_done',
'move_ids.quantity',
)
def _compute_declared_value(self):
for rec in self.filtered(lambda p: p.automatic_declare_value and p.state not in ['done', 'cancel']):
Expand All @@ -155,7 +156,7 @@ def _compute_declared_value(self):
for move_line in rec.move_ids.filtered(
lambda x: x.state != 'cancel'):
order_line = move_line.sale_line_id
if move_line.quantity_done:
if move_line.quantity:
inmediate_transfer = False
if order_line:
pricelist = rec.sale_id.pricelist_id
Expand All @@ -164,7 +165,7 @@ def _compute_declared_value(self):
stock_bom_lines |= move_line
continue
so_product_qty = move_line.product_uom_qty
so_qty_done = move_line.quantity_done
so_qty_done = move_line.quantity
# convert quantities if move line uom and sale line uom
# are different
if move_line.product_uom != order_line.product_uom:
Expand All @@ -174,7 +175,7 @@ def _compute_declared_value(self):
order_line.product_uom)
so_qty_done = \
move_line.product_uom._compute_quantity(
move_line.quantity_done,
move_line.quantity,
order_line.product_uom)
picking_value += (order_line.price_reduce_taxexcl *
so_product_qty)
Expand All @@ -185,11 +186,11 @@ def _compute_declared_value(self):
price = rec.picking_type_id.pricelist_id.with_context(
uom=move_line.product_uom.id)._price_get(
move_line.product_id,
move_line.quantity_done or 1.0,
move_line.quantity or 1.0,
partner=rec.partner_id.id)[
rec.picking_type_id.pricelist_id.id]
picking_value += (price * move_line.product_uom_qty)
done_value += (price * move_line.quantity_done)
done_value += (price * move_line.quantity)

# This is for product in a kit (should only happen if sale_mrp ins
# installed). If it is bom we only compute amount if all bom
Expand All @@ -216,7 +217,7 @@ def _compute_declared_value(self):
picking_avg.append((
move.product_uom_qty / bom_quantity))
done_avg.append(
(move.quantity_done / bom_quantity))
(move.quantity / bom_quantity))
picking_value += so_bom_line.price_reduce_taxexcl * (
sum(picking_avg) / len(picking_avg))
done_value += so_bom_line.price_reduce_taxexcl * (
Expand Down
1 change: 1 addition & 0 deletions stock_voucher/models/stock_picking_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class StockPickingType(models.Model):
'stock.book',
'Book',
help='Book suggested for pickings of this type',
check_company=True
)
pricelist_id = fields.Many2one(
'product.pricelist',
Expand Down
3 changes: 2 additions & 1 deletion stock_voucher/views/stock_book_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
<record id="stock_book_actions" model="ir.actions.act_window">
<field name="name">Books</field>
<field name="res_model">stock.book</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">tree</field>
<field name="context">{}</field>
</record>

<menuitem name="Books" id="menu_books" sequence="20" action="stock_book_actions" parent="stock.menu_warehouse_config" />
Expand Down
8 changes: 4 additions & 4 deletions stock_voucher/views/stock_picking_type_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<xpath expr="//sheet//group" position="after">
<group id="stock_voucher">
<group>
<field name="book_id" attrs="{'invisible':[('code','=','incoming')]}" domain="[('company_id', '=', company_id)]"/>
<field name="voucher_number_unique" attrs="{'invisible':[('code','!=','incoming')]}"/>
<field name="book_id" invisible="code == 'incoming'"/>
<field name="voucher_number_unique" invisible="code != 'incoming'"/>
<field name="pricelist_id"/>
</group>
<group>
<field name="book_required" attrs="{'invisible':[('code','=','incoming')]}"/>
<field name="voucher_required" attrs="{'invisible':[('code','!=','incoming')]}"/>
<field name="book_required" invisible="code == 'incoming'"/>
<field name="voucher_required" invisible="code != 'incoming'"/>
<field name="automatic_declare_value"/>
<field name="restrict_number_package"/>
</group>
Expand Down
14 changes: 7 additions & 7 deletions stock_voucher/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@

<field name="partner_id" position="after">
<!-- no lo hacemos requerido por vista -->
<field name="book_id" attrs="{'invisible': [('picking_type_code','=','incoming')], 'readonly': [('voucher_ids','!=',[])]}" domain="[('company_id', '=', company_id)]"/>
<field name="next_number" attrs="{'invisible': ['|', ('book_id','=',False), ('voucher_ids','!=',[])]}"/>
<field name="voucher_ids" attrs="{'readonly': [('picking_type_code','!=','incoming')]}" widget="many2many_tags" context="{'default_picking_id': id}" domain="[('id', '=', False)]" options="{'create':True, 'create_edit':True}"/>
<field name="book_id" invisible="picking_type_code == 'incoming'" readonly="voucher_ids"/>
<field name="next_number" invisible="not book_id or voucher_ids"/>
<field name="voucher_ids" readonly="picking_type_code != 'incoming'" widget="many2many_tags" context="{'default_picking_id': id}" domain="[('id', '=', False)]" />
</field>

<field name="origin" position="after">
<field name="number_of_packages" attrs="{'invisible': [('picking_type_code','=','incoming')]}"/>
<field name="declared_value" attrs="{'invisible': [('picking_type_code','=','incoming')]}"/>
<field name="number_of_packages" invisible="picking_type_code == 'incoming'"/>
<field name="declared_value" invisible="picking_type_code == 'incoming'"/>
</field>

<button name="do_print_picking" position="after">
<button name="%(action_stock_print_voucher)d" string="Vouchers" type="action" attrs="{'invisible': ['|',('book_id','=',False),'|', ('picking_type_code','=','incoming'), ('state','!=','done')]}" context="{'picking_id': id}"/>
<button name="%(action_stock_print_voucher)d" string="Vouchers" type="action" attrs="{'invisible': ['|',('book_id','!=',False),'|', ('picking_type_code','=','incoming'), ('state','!=','done')]}" class="oe_highlight" context="{'picking_id': id}"/>
<button name="%(action_stock_print_voucher)d" string="Vouchers" type="action" invisible="not book_id or picking_type_code == 'incoming' or state != 'done'" context="{'picking_id': id}"/>
<button name="%(action_stock_print_voucher)d" string="Vouchers" type="action" invisible="book_id or picking_type_code == 'incoming' or state != 'done'" class="oe_highlight" context="{'picking_id': id}"/>
</button>
</field>
</record>
Expand Down
1 change: 0 additions & 1 deletion stock_voucher/wizards/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# directory
##############################################################################
from . import stock_print_stock_voucher
from . import stock_immediate_transfer
from . import stock_backorder_confirmation
31 changes: 0 additions & 31 deletions stock_voucher/wizards/stock_immediate_transfer.py

This file was deleted.

24 changes: 12 additions & 12 deletions stock_voucher/wizards/stock_print_stock_voucher_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
<field name="model">stock.print_stock_voucher</field>
<field name="arch" type="xml">
<form string="Print Stock Voucher">
<div attrs="{'invisible':[('printed', '!=', True),('with_vouchers', '!=', True)]}">
<div invisible="not printed and not with_vouchers">
<h3><strong>THE VOUCHER IT'S PRINTED AND ASSIGNED.</strong></h3>
</div>
<group>
<field name="picking_id" invisible="1"/>
<field name="printed" invisible="1"/>
<field name="with_vouchers" invisible="1"/>
<field name="lines_per_voucher" invisible="1"/>
<field name="book_id" attrs="{'invisible':[('with_vouchers', '=', True)],'required':[('with_vouchers', '=', False)],'readonly':[('printed', '=', True)]}"/>
<field name="book_id" invisible="with_vouchers" readonly="printed" required="not with_vouchers"/>
</group>
<group attrs="{'invisible':[('with_vouchers', '=', True)]}">
<group invisible="with_vouchers">
<field name="next_voucher_number"/>
<field name="estimated_number_of_pages" attrs="{'invisible':[('lines_per_voucher', '=', 0)],'required':[('lines_per_voucher', '!=', 0)]}"/>
<field name="estimated_number_of_pages" invisible="lines_per_voucher == 0" required="lines_per_voucher != 0"/>
</group>
<footer>
<!-- Boton compartido una vez que se asignaro -->
<button name="do_print_voucher" type="object" string="Print" attrs="{'invisible':[('with_vouchers', '=', False)]}"/>
<button name="do_print_voucher" type="object" string="Print" invisible="not with_vouchers"/>
<!-- Botones para remitos que usan una hoja -->
<button name="do_print_and_assign" type="object" class="oe_highlight" string="Print and Assign" attrs="{'invisible':['|',('lines_per_voucher', '!=', 0),('with_vouchers', '=', True)]}"/>
<button name="do_print_and_assign" type="object" class="oe_highlight" string="Print and Assign" invisible="lines_per_voucher != 0 or with_vouchers"/>
<!-- Botones para remitos que usan varias hojas -->
<button name="do_print_voucher" type="object" string="Print" attrs="{'invisible':['|','|',('lines_per_voucher', '=', 0),('with_vouchers', '=', True),('printed', '=', True)]}" class="oe_highlight"/>
<button name="do_print_voucher" type="object" string="Print" attrs="{'invisible':['|','|',('lines_per_voucher', '=', 0),('with_vouchers', '=', True),('printed', '=', False)]}"/>
<button name="do_print_and_assign" type="object" string="Print and Assign" attrs="{'invisible':['|',('lines_per_voucher', '=', 0),('with_vouchers', '=', True)]}"/>
<button name="assign_numbers" type="object" string="Assign Numbers" attrs="{'invisible':['|','|',('lines_per_voucher', '=', 0),('with_vouchers', '=', True),('printed', '=', True)]}"/>
<button name="assign_numbers" type="object" string="Assign Numbers" attrs="{'invisible':['|','|',('lines_per_voucher', '=', 0),('with_vouchers', '=', True),('printed', '=', False)]}" class="oe_highlight"/>
<button name="do_print_voucher" type="object" string="Print" invisible="lines_per_voucher == 0 or with_vouchers or printed" class="oe_highlight"/>
<button name="do_print_voucher" type="object" string="Print" invisible="lines_per_voucher == 0 or with_vouchers or not printed"/>
<button name="do_print_and_assign" type="object" string="Print and Assign" invisible="lines_per_voucher == 0 or with_vouchers"/>
<button name="assign_numbers" type="object" string="Assign Numbers" invisible="lines_per_voucher == 0 or with_vouchers or printed"/>
<button name="assign_numbers" type="object" string="Assign Numbers" invisible="lines_per_voucher == 0 or with_vouchers or not printed" class="oe_highlight"/>

<!-- Clean numbers -->
<button name="do_clean" type="object" string="Clean Voucher Data" attrs="{'invisible':[('with_vouchers', '=', False)]}"/>
<button name="do_clean" type="object" string="Clean Voucher Data" invisible="not with_vouchers"/>
or
<button string="Close" special="cancel"/>
</footer>
Expand Down

0 comments on commit 7328846

Please sign in to comment.