[IMP] stock_picking_report_undelivered_product: black, isort

This commit is contained in:
sergio-teruel
2021-02-17 16:08:55 +01:00
parent a8076b1d8c
commit 0f91716550
6 changed files with 150 additions and 114 deletions

View File

@@ -9,14 +9,12 @@
"website": "https://www.tecnativa.com",
"category": "Warehouse",
"license": "AGPL-3",
"depends": [
"stock",
],
"depends": ["stock"],
"data": [
'views/product_views.xml',
'views/report_deliveryslip.xml',
'views/res_config_settings_views.xml',
'views/res_partner_view.xml',
"views/product_views.xml",
"views/report_deliveryslip.xml",
"views/res_config_settings_views.xml",
"views/res_partner_view.xml",
],
'installable': True,
"installable": True,
}

View File

@@ -5,9 +5,8 @@ from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
_inherit = "product.template"
display_undelivered_in_picking = fields.Boolean(
string='Display undelivered in picking',
default=True,
string="Display undelivered in picking", default=True
)

View File

@@ -5,17 +5,21 @@ from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
_inherit = "res.config.settings"
undelivered_product_slip_report_method = fields.Selection(
[
('all', 'Display all undelivered product lines'),
('partially_undelivered',
'Display only partially undelivered product lines'),
('completely_undelivered',
'Display only completely undelivered product lines'),
("all", "Display all undelivered product lines"),
(
"partially_undelivered",
"Display only partially undelivered product lines",
),
(
"completely_undelivered",
"Display only completely undelivered product lines",
),
],
string='Method to display undelivered product lines in report picking',
string="Method to display undelivered product lines in report picking",
related="company_id.undelivered_product_slip_report_method",
readonly=False,
)
@@ -26,12 +30,16 @@ class Company(models.Model):
undelivered_product_slip_report_method = fields.Selection(
[
('all', 'Display all undelivered product lines'),
('partially_undelivered',
'Display only partially undelivered product lines'),
('completely_undelivered',
'Display only completely undelivered product lines'),
("all", "Display all undelivered product lines"),
(
"partially_undelivered",
"Display only partially undelivered product lines",
),
(
"completely_undelivered",
"Display only completely undelivered product lines",
),
],
string='Method to display undelivered product lines in report picking',
default='all'
string="Method to display undelivered product lines in report picking",
default="all",
)

View File

@@ -5,9 +5,8 @@ from odoo import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
_inherit = "res.partner"
display_undelivered_in_picking = fields.Boolean(
string='Display undelivered in picking',
default=True,
string="Display undelivered in picking", default=True
)

View File

@@ -5,12 +5,10 @@ from odoo import fields, models
class StockMove(models.Model):
_inherit = 'stock.move'
_inherit = "stock.move"
splitted_stock_move_orig_id = fields.Many2one(
comodel_name='stock.move',
string="Splitted from",
readonly=True,
comodel_name="stock.move", string="Splitted from", readonly=True
)
def _prepare_move_split_vals(self, qty):
@@ -18,5 +16,5 @@ class StockMove(models.Model):
Store origin stock move which create splitted move.
"""
vals = super(StockMove, self)._prepare_move_split_vals(qty)
vals['splitted_stock_move_orig_id'] = self.id
vals["splitted_stock_move_orig_id"] = self.id
return vals

View File

@@ -5,50 +5,61 @@ from odoo.tests.common import Form
class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
def setUp(self):
super().setUp()
self.ResPartner = self.env['res.partner']
self.ProductProduct = self.env['product.product']
self.StockPicking = self.env['stock.picking']
self.StockQuant = self.env['stock.quant']
self.ResPartner = self.env["res.partner"]
self.ProductProduct = self.env["product.product"]
self.StockPicking = self.env["stock.picking"]
self.StockQuant = self.env["stock.quant"]
self.warehouse = self.env.ref('stock.warehouse0')
self.stock_location = self.env.ref('stock.stock_location_stock')
self.customer_location = self.env.ref('stock.stock_location_customers')
self.picking_type_out = self.env.ref('stock.picking_type_out')
self.warehouse = self.env.ref("stock.warehouse0")
self.stock_location = self.env.ref("stock.stock_location_stock")
self.customer_location = self.env.ref("stock.stock_location_customers")
self.picking_type_out = self.env.ref("stock.picking_type_out")
self.partner_display = self.ResPartner.create({
'name': 'Partner for test display',
'customer': True,
'display_undelivered_in_picking': True,
})
self.partner_no_display = self.ResPartner.create({
'name': 'Partner for test on display',
'customer': True,
'display_undelivered_in_picking': False,
})
self.partner_display = self.ResPartner.create(
{
"name": "Partner for test display",
"customer": True,
"display_undelivered_in_picking": True,
}
)
self.partner_no_display = self.ResPartner.create(
{
"name": "Partner for test on display",
"customer": True,
"display_undelivered_in_picking": False,
}
)
self.product_display = self.ProductProduct.create({
'name': 'Test product undelivered display',
'display_undelivered_in_picking': True,
'type': 'product',
})
self.product_no_display = self.ProductProduct.create({
'name': 'Test product undelivered no display',
'display_undelivered_in_picking': False,
'type': 'product',
})
self.product_no_display_wo_stock = self.ProductProduct.create({
'name': 'Test product undelivered no display without stock',
'display_undelivered_in_picking': False,
'type': 'product',
})
self.StockQuant.create({
'product_id': self.product_no_display.id,
'location_id': self.warehouse.lot_stock_id.id,
'quantity': 2000,
})
self.product_display = self.ProductProduct.create(
{
"name": "Test product undelivered display",
"display_undelivered_in_picking": True,
"type": "product",
}
)
self.product_no_display = self.ProductProduct.create(
{
"name": "Test product undelivered no display",
"display_undelivered_in_picking": False,
"type": "product",
}
)
self.product_no_display_wo_stock = self.ProductProduct.create(
{
"name": "Test product undelivered no display without stock",
"display_undelivered_in_picking": False,
"type": "product",
}
)
self.StockQuant.create(
{
"product_id": self.product_no_display.id,
"location_id": self.warehouse.lot_stock_id.id,
"quantity": 2000,
}
)
def _create_picking(self, partner):
picking_form = Form(self.StockPicking)
@@ -74,9 +85,11 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
picking.action_done()
# Cancel backorder
picking.backorder_ids.action_cancel()
res = self.env['ir.actions.report']._get_report_from_name(
'stock.report_deliveryslip'
).render_qweb_html(picking.ids)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
.render_qweb_html(picking.ids)
)
self.assertIn("undelivered_product", str(res[0]))
def test_no_displayed_customer(self):
@@ -87,42 +100,53 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
picking.action_done()
# Cancel backorder
picking.backorder_ids.action_cancel()
res = self.env['ir.actions.report']._get_report_from_name(
'stock.report_deliveryslip'
).render_qweb_html(picking.ids)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
.render_qweb_html(picking.ids)
)
self.assertNotIn("undelivered_product", str(res[0]))
def test_no_displayed_product(self):
picking = self._create_picking(self.partner_display)
picking.move_lines.filtered(
lambda l: l.product_id == self.product_display).unlink()
lambda l: l.product_id == self.product_display
).unlink()
picking.action_confirm()
picking.action_assign()
picking.move_line_ids.qty_done = 10.00
picking.action_done()
# Cancel backorder
picking.backorder_ids.action_cancel()
res = self.env['ir.actions.report']._get_report_from_name(
'stock.report_deliveryslip'
).render_qweb_html(picking.ids)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
.render_qweb_html(picking.ids)
)
self.assertNotIn("undelivered_product", str(res[0]))
def test_picking_report_method(self):
product = self.ProductProduct.create({
'name': 'test01',
'display_undelivered_in_picking': True,
'type': 'product',
})
product2 = self.ProductProduct.create({
'name': 'test02',
'display_undelivered_in_picking': True,
'type': 'product',
})
self.StockQuant.create({
'product_id': product.id,
'location_id': self.warehouse.lot_stock_id.id,
'quantity': 2000,
})
product = self.ProductProduct.create(
{
"name": "test01",
"display_undelivered_in_picking": True,
"type": "product",
}
)
product2 = self.ProductProduct.create(
{
"name": "test02",
"display_undelivered_in_picking": True,
"type": "product",
}
)
self.StockQuant.create(
{
"product_id": product.id,
"location_id": self.warehouse.lot_stock_id.id,
"quantity": 2000,
}
)
picking_form = Form(self.StockPicking)
picking_form.picking_type_id = self.picking_type_out
picking_form.partner_id = self.partner_display
@@ -143,30 +167,40 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
# Empty setting method field
picking.company_id.undelivered_product_slip_report_method = False
res = self.env['ir.actions.report']._get_report_from_name(
'stock.report_deliveryslip'
).render_qweb_html(picking.ids)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
.render_qweb_html(picking.ids)
)
self.assertIn("test02", str(res[0]))
# Print all undelivered lines, partial and completely lines
picking.company_id.undelivered_product_slip_report_method = 'all'
res = self.env['ir.actions.report']._get_report_from_name(
'stock.report_deliveryslip'
).render_qweb_html(picking.ids)
picking.company_id.undelivered_product_slip_report_method = "all"
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
.render_qweb_html(picking.ids)
)
self.assertIn("test02", str(res[0]))
# Print only partial undelivered lines
picking.company_id.\
undelivered_product_slip_report_method = 'partially_undelivered'
res = self.env['ir.actions.report']._get_report_from_name(
'stock.report_deliveryslip'
).render_qweb_html(picking.ids)
picking.company_id.undelivered_product_slip_report_method = (
"partially_undelivered"
)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
.render_qweb_html(picking.ids)
)
self.assertNotIn("test02", str(res[0]))
# Print only completely undelivered lines
picking.company_id.\
undelivered_product_slip_report_method = 'completely_undelivered'
res = self.env['ir.actions.report']._get_report_from_name(
'stock.report_deliveryslip'
).render_qweb_html(picking.ids)
picking.company_id.undelivered_product_slip_report_method = (
"completely_undelivered"
)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
.render_qweb_html(picking.ids)
)
self.assertNotIn("partially_undelivered_line", str(res[0]))