-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] Separate view and py files by model. [FIX] Update README.
- Loading branch information
Valentino
committed
Sep 4, 2018
1 parent
d92dcc3
commit 5ce67a9
Showing
12 changed files
with
154 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import models, api, fields, _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
|
||
_inherit = 'stock.move.line' | ||
|
||
block_additional_quantiy = fields.Boolean( | ||
related='picking_id.block_additional_quantiy', | ||
readonly=True, | ||
default=True, | ||
) | ||
|
||
@api.constrains('qty_done') | ||
def _check_quantity(self): | ||
for pack in self: | ||
if pack.picking_id.block_additional_quantiy and pack.\ | ||
product_qty < pack.qty_done: | ||
raise ValidationError(_( | ||
'You can not transfer a product without a move on the ' | ||
'picking!')) | ||
|
||
# @api.model | ||
# def create(self, vals): | ||
# op = super(StockMoveLine, self).create(vals) | ||
# if op.fresh_record | ||
# and op.picking_id.picking_type_id.block_additional_quantiy: | ||
# raise ValidationError(_( | ||
# 'You can not add operations to this picking')) | ||
# return op |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import models, fields, api, _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class StockPicking(models.Model): | ||
|
||
_inherit = 'stock.picking' | ||
|
||
block_additional_quantiy = fields.Boolean( | ||
related='picking_type_id.block_additional_quantiy', | ||
readonly=True, | ||
) | ||
|
||
@api.multi | ||
def unlink(self): | ||
""" | ||
To avoid errors we block deletion of pickings in other state than | ||
draft or cancel | ||
""" | ||
not_del_pickings = self.filtered( | ||
lambda x: x.picking_type_id.block_picking_deletion) | ||
if not_del_pickings: | ||
raise ValidationError(_( | ||
'You can not delete this pickings because "Block picking ' | ||
'deletion" is enable on the picking type "%s".\n' | ||
'Picking Ids: %s') % ( | ||
not_del_pickings.ids, self.picking_type_id.name)) | ||
return super(StockPicking, self).unlink() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import fields, models | ||
|
||
|
||
class StockPickingType(models.Model): | ||
|
||
_inherit = 'stock.picking.type' | ||
|
||
block_additional_quantiy = fields.Boolean( | ||
string="Block additional quantiy", | ||
help="Restrict additional quantity", | ||
) | ||
|
||
block_picking_deletion = fields.Boolean( | ||
default=True, | ||
help="Do not allow to remove pickings", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
<?xml version="1.0"?> | ||
<odoo> | ||
<data> | ||
|
||
<record model="res.groups" id="group_restrict_edit_picking"> | ||
<field name="name">Restrict Edit Blocked Pickings</field> | ||
</record> | ||
|
||
</data> | ||
</odoo> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0"?> | ||
<odoo> | ||
|
||
<record id="view_picking_type_form" model="ir.ui.view"> | ||
<field name="name">stock.picking.type.form</field> | ||
<field name="model">stock.picking.type</field> | ||
<field name="inherit_id" ref="stock.view_picking_type_form"/> | ||
<field name="arch" type="xml"> | ||
<group position="inside"> | ||
<group string="Stock"> | ||
<field name="block_additional_quantiy"/> | ||
<field name="block_picking_deletion"/> | ||
</group> | ||
</group> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0"?> | ||
<odoo> | ||
|
||
<record id="view_picking_form" model="ir.ui.view"> | ||
<field name="name">stock.picking.form</field> | ||
<field name="model">stock.picking</field> | ||
<field name="inherit_id" ref="stock.view_picking_form"/> | ||
|
||
<!-- por si stock usability esta instalado, queremos que esta pise aquella --> | ||
<field name="priority">20</field> | ||
<field name="groups_id" eval="[(6, 0, [ref('group_restrict_edit_picking')])]"/> | ||
<field name="arch" type="xml"> | ||
<field name="partner_id" position="after"> | ||
<field name="block_additional_quantiy" invisible="1"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
Oops, something went wrong.