[CLN] sale_stock: cleaning and linting

This commit is contained in:
Thibault Delavallée
2016-07-12 17:53:49 +02:00
parent 3bf3d15fc5
commit d56ccae9f1
10 changed files with 42 additions and 30 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import fields, models
from odoo import fields, models
class AccountInvoice(models.Model):
+1 -1
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import models
from odoo import models
class ProcurementOrder(models.Model):
+1 -1
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import api, models
from odoo import api, models
class ProductProduct(models.Model):
+7 -5
View File
@@ -1,13 +1,15 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import fields, models
from odoo import fields, models
class company(models.Model):
_inherit = 'res.company'
security_lead = fields.Float('Sales Safety Days', required=True, default = 0.0,
help="Margin of error for dates promised to customers. "\
"Products will be scheduled for procurement and delivery "\
"that many days earlier than the actual promised date, to "\
security_lead = fields.Float(
'Sales Safety Days', default=0.0, required=True,
help="Margin of error for dates promised to customers. "
"Products will be scheduled for procurement and delivery "
"that many days earlier than the actual promised date, to "
"cope with unexpected delays in the supply chain.")
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import SUPERUSER_ID
from openerp import api, fields, models, _
from openerp.exceptions import AccessError
from odoo import api, fields, models, _
from odoo.exceptions import AccessError
class SaleConfiguration(models.TransientModel):
_inherit = 'sale.config.settings'
@@ -43,5 +43,4 @@ class SaleConfiguration(models.TransientModel):
default_picking_policy = 'one' if self.default_picking_policy else 'direct'
self.env['ir.values'].sudo().set_default('sale.order', 'picking_policy', default_picking_policy)
res = super(SaleConfiguration, self).set_sale_defaults()
return res
return super(SaleConfiguration, self).set_sale_defaults()
+10 -5
View File
@@ -2,9 +2,10 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from datetime import datetime, timedelta
from openerp import api, fields, models, _
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, float_compare
from openerp.exceptions import UserError
from odoo import api, fields, models, _
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, float_compare
from odoo.exceptions import UserError
class SaleOrder(models.Model):
@@ -16,13 +17,16 @@ class SaleOrder(models.Model):
warehouse_ids = self.env['stock.warehouse'].search([('company_id', '=', company)], limit=1)
return warehouse_ids
incoterm = fields.Many2one('stock.incoterms', 'Incoterms', help="International Commercial Terms are a series of predefined commercial terms used in international transactions.")
incoterm = fields.Many2one(
'stock.incoterms', 'Incoterms',
help="International Commercial Terms are a series of predefined commercial terms used in international transactions.")
picking_policy = fields.Selection([
('direct', 'Deliver each product when available'),
('one', 'Deliver all products at once')],
string='Shipping Policy', required=True, readonly=True, default='direct',
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]})
warehouse_id = fields.Many2one('stock.warehouse', string='Warehouse',
warehouse_id = fields.Many2one(
'stock.warehouse', string='Warehouse',
required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
default=_default_warehouse_id)
picking_ids = fields.Many2many('stock.picking', compute='_compute_picking_ids', string='Picking associated to this sale')
@@ -93,6 +97,7 @@ class SaleOrder(models.Model):
super(SaleOrder, self)._get_customer_lead(product_tmpl_id)
return product_tmpl_id.sale_delay
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
+12 -6
View File
@@ -1,18 +1,20 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import api, fields, models
from odoo import api, fields, models
class StockLocationRoute(models.Model):
_inherit = "stock.location.route"
sale_selectable = fields.Boolean(string="Selectable on Sales Order Line")
sale_selectable = fields.Boolean("Selectable on Sales Order Line")
class StockMove(models.Model):
_inherit = "stock.move"
to_refund_so = fields.Boolean(string="To Refund in SO", default=False,
to_refund_so = fields.Boolean(
"To Refund in SO", default=False,
help='Trigger a decrease of the delivered quantity in the associated Sale Order')
@api.multi
@@ -35,11 +37,13 @@ class StockMove(models.Model):
if move.picking_id and move.picking_id.group_id:
picking = move.picking_id
order = self.env['sale.order'].search([('procurement_group_id', '=', picking.group_id.id)])
picking.message_post_with_view('mail.message_origin_link',
picking.message_post_with_view(
'mail.message_origin_link',
values={'self': picking, 'origin': order},
subtype_id=self.env.ref('mail.mt_note').id)
return result
class StockPicking(models.Model):
_inherit = 'stock.picking'
@@ -68,11 +72,13 @@ class StockPicking(models.Model):
for picking in self.filtered(lambda pick: pick.picking_type_id.code == 'outgoing'):
backorder = picking.search([('backorder_id', '=', picking.id)])
order = self.env['sale.order'].search([('procurement_group_id', '=', backorder.group_id.id)])
backorder.message_post_with_view('mail.message_origin_link',
backorder.message_post_with_view(
'mail.message_origin_link',
values={'self': backorder, 'origin': order},
subtype_id=self.env.ref('mail.mt_note').id)
return res
class StockReturnPicking(models.TransientModel):
_inherit = "stock.return.picking"
@@ -91,4 +97,4 @@ class StockReturnPicking(models.TransientModel):
class StockReturnPickingLine(models.TransientModel):
_inherit = "stock.return.picking.line"
to_refund_so = fields.Boolean(string="To Refund", help='Trigger a decrease of the delivered quantity in the associated Sale Order')
to_refund_so = fields.Boolean(string="To Refund", help='Trigger a decrease of the delivered quantity in the associated Sale Order')
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<openerp>
<odoo>
<data>
<record id="view_company_form_inherit_sale_stock" model="ir.ui.view">
<field name="name">res.company.mrp.config</field>
@@ -13,4 +13,4 @@
</field>
</record>
</data>
</openerp>
</odoo>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<openerp>
<odoo>
<data>
<record id="view_order_form_inherit_sale_stock" model="ir.ui.view">
@@ -51,4 +51,4 @@
</record>
</data>
</openerp>
</odoo>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data>
<menuitem id="base.menu_aftersale" name="After-Sale"
@@ -30,4 +30,4 @@
</record>
</data>
</openerp>
</odoo>