Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 31 additions & 6 deletions tko_product_update_qty/i18n/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-07-31 18:30+0000\n"
"PO-Revision-Date: 2018-07-31 18:30+0000\n"
"POT-Creation-Date: 2018-08-30 16:10+0000\n"
"PO-Revision-Date: 2018-08-30 16:10+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -21,11 +21,22 @@ msgid "Change Product Quantity"
msgstr "Alterar Quantidade do Produto"

#. module: tko_product_update_qty
#: code:addons/tko_product_update_qty/wizard/stock_change_product_qty.py:58
#: model:ir.model.fields,help:tko_product_update_qty.field_stock_change_product_qty_show_new_quantity
msgid "Duplicate field only to be able to make it readonly on view, onchange doesnt pass value of readonly field"
msgstr "Duplicate field only to be able to make it readonly on view, onchange doesnt pass value of readonly field"

#. module: tko_product_update_qty
#: code:addons/tko_product_update_qty/wizard/stock_change_product_qty.py:62
#, python-format
msgid "INV: %s"
msgstr "INV: %s"

#. module: tko_product_update_qty
#: selection:stock.change.product.qty,mode:0
#: selection:stock.inventory.line,mode:0
msgid "Input"
msgstr "Input"

#. module: tko_product_update_qty
#: model:ir.model,name:tko_product_update_qty.model_stock_inventory
msgid "Inventory"
Expand All @@ -40,27 +51,41 @@ msgstr "Linha do Inventário"
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_change_product_qty_mode
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_inventory_line_mode
msgid "Mode"
msgstr "Mode"
msgstr "Modo"

#. module: tko_product_update_qty
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_change_product_qty_show_new_quantity
msgid "New Quantity on Hand"
msgstr "Nova Quantidade na Mão"

#. module: tko_product_update_qty
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_change_product_qty_old_quantity
msgid "Old Qty"
msgstr "Old Qty"
msgstr "Quantidade Antiga"

#. module: tko_product_update_qty
#: selection:stock.change.product.qty,mode:0
#: selection:stock.inventory.line,mode:0
msgid "Output"
msgstr "Output"

#. module: tko_product_update_qty
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_change_product_qty_reason
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_inventory_line_reason
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_inventory_reason
#: model:ir.ui.view,arch_db:tko_product_update_qty.view_inventory_form_inherit
msgid "Reason"
msgstr "Motivo da atualização"

#. module: tko_product_update_qty
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_change_product_qty_update_quantity
msgid "Update Qty"
msgstr "Update Qty"
msgstr "Atualizar Quantidade"

#. module: tko_product_update_qty
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_inventory_line_user_id
#: model:ir.model.fields,field_description:tko_product_update_qty.field_stock_inventory_user_id
#: model:ir.ui.view,arch_db:tko_product_update_qty.view_move_line_form_inherit
#: model:ir.ui.view,arch_db:tko_product_update_qty.view_move_line_tree_inherit
msgid "User"
msgstr "Usuário"
2 changes: 1 addition & 1 deletion tko_product_update_qty/models/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class StockInventoryLine(models.Model):
reason = fields.Char(string='Reason', related='inventory_id.reason', store=True)
user_id = fields.Many2one('res.users', 'User', readonly=True, related='inventory_id.user_id',
default=lambda self: self.env.uid)
mode = fields.Selection([('p', ' + '), ('n', ' - ')], compute='get_mode', default='p', required=True, string='Mode')
mode = fields.Selection([('p', 'Input'), ('n', 'Output')], compute='get_mode', default='p', required=True, string='Mode')

@api.one
@api.depends('product_qty', 'theoretical_qty')
Expand Down
23 changes: 22 additions & 1 deletion tko_product_update_qty/views/inventory_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</field>
</record>

<record id="view_inventory_form_inherit" model="ir.ui.view">
<record id="view_inventory_tree_inherit" model="ir.ui.view">
<field name="name">stock.inventory.form.inherit</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_tree"/>
Expand All @@ -26,4 +26,25 @@
</field>
</record>

<record id="view_move_line_tree_inherit" model="ir.ui.view">
<field name="name">stock.inventory.tree.inherit</field>
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_move_line_tree"/>
<field name="arch" type="xml">
<field name="date" position="after">
<field name="create_uid" string="User"/>
</field>
</field>
</record>
<record id="view_move_line_form_inherit" model="ir.ui.view">
<field name="name">stock.inventory.form.inherit</field>
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_move_line_form"/>
<field name="arch" type="xml">
<field name="date" position="after">
<field name="create_uid" string="User"/>
</field>
</field>
</record>

</odoo>
24 changes: 15 additions & 9 deletions tko_product_update_qty/wizard/stock_change_product_qty.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from odoo import api, models, fields, _
from odoo import tools
from odoo.exceptions import Warning as UserError


class StockChangeProductQty(models.TransientModel):
_inherit = "stock.change.product.qty"

old_quantity = fields.Float('Old Qty', readonly=True)
update_quantity = fields.Float('Update Qty')
mode = fields.Selection([('p', ' + '), ('n', ' - ')], default='p', required=True, string='Mode')
mode = fields.Selection([('p', 'Input'), ('n', 'Output')], default='p', required=True, string='Mode')
reason = fields.Text('Reason')
show_new_quantity = fields.Float('New Quantity on Hand', help='Duplicate field only to be able to make it readonly on view, onchange doesnt pass value of readonly field')

# When a user updates stock qty on the product form, propose the
# right location to update stock.
Expand All @@ -27,22 +29,26 @@ def onchange_mode(self):
if 'new_quantity' not in self._context.keys():
if self.mode == 'p':
self.new_quantity = self.old_quantity + self.update_quantity
self.show_new_quantity = self.old_quantity + self.update_quantity
else:
self.new_quantity = self.old_quantity - self.update_quantity
self.show_new_quantity = self.old_quantity - self.update_quantity

@api.onchange('new_quantity')
def onchange_new_quantity(self):
if self.new_quantity >= self.old_quantity:
self.mode = 'p'
self.update_quantity = self.new_quantity - self.old_quantity
else:
self.mode = 'n'
self.update_quantity = self.new_quantity + self.old_quantity
# @api.onchange('new_quantity')
# def onchange_new_quantity(self):
# if self.new_quantity >= self.old_quantity:
# self.mode = 'p'
# self.update_quantity = self.new_quantity - self.old_quantity
# else:
# self.mode = 'n'
# self.update_quantity = self.new_quantity + self.old_quantity

def change_product_qty(self):
""" Changes the Product Quantity by making a Physical Inventory. """
Inventory = self.env['stock.inventory']
for wizard in self:
if wizard.new_quantity < 0:
raise UserError('Quantity can not be less than zero.')
product = wizard.product_id.with_context(location=wizard.location_id.id, lot_id=wizard.lot_id.id)
line_data = wizard._action_start_line()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
</field>
<field name="new_quantity" position="attributes">
<attribute name="groups">stock.group_stock_manager</attribute>
<attribute name="invisible">1</attribute>
</field>
<field name="new_quantity" position="after">
<field name="show_new_quantity" groups="stock.group_stock_manager" readonly="1"/>
<separator/>
<field name="reason" colspan="4" />
</field>
Expand Down