[PATCH] Upstream patch - 05042023

This commit is contained in:
Parthiv Patel
2023-04-05 08:35:43 +00:00
parent 98b0697e76
commit 624293a45d
6 changed files with 50 additions and 6 deletions

View File

@@ -156,8 +156,7 @@ class AccountMove(models.Model):
else:
number_ref = str(move.name) + " " + nik
shipping_partner = self.env['res.partner'].browse(move._get_invoice_delivery_partner_id())
street = ', '.join([x for x in (shipping_partner.street, shipping_partner.street2) if x])
street = ', '.join([x for x in (move.partner_id.street, move.partner_id.street2) if x])
invoice_npwp = '000000000000000'
if move.partner_id.vat and len(move.partner_id.vat) >= 12:
@@ -175,7 +174,7 @@ class AccountMove(models.Model):
eTax['TANGGAL_FAKTUR'] = '{0}/{1}/{2}'.format(move.invoice_date.day, move.invoice_date.month, move.invoice_date.year)
eTax['NPWP'] = invoice_npwp
eTax['NAMA'] = move.partner_id.name if eTax['NPWP'] == '000000000000000' else move.partner_id.l10n_id_tax_name or move.partner_id.name
eTax['ALAMAT_LENGKAP'] = move.partner_id.contact_address.replace('\n', '') if eTax['NPWP'] == '000000000000000' else shipping_partner.l10n_id_tax_address or street
eTax['ALAMAT_LENGKAP'] = move.partner_id.contact_address.replace('\n', '') if eTax['NPWP'] == '000000000000000' else move.partner_id.l10n_id_tax_address or street
eTax['JUMLAH_DPP'] = int(float_round(move.amount_untaxed, 0)) # currency rounded to the unit
eTax['JUMLAH_PPN'] = int(float_round(move.amount_tax, 0))
eTax['ID_KETERANGAN_TAMBAHAN'] = '1' if move.l10n_id_kode_transaksi == '07' else ''

View File

@@ -9,7 +9,7 @@
'category': 'Accounting/Localizations/Account Charts',
'description': """
This is the base module to manage the accounting chart for Morocco.
=================================================================
===================================================================
Ce Module charge le modèle du plan de comptes standard Marocain et permet de
générer les états comptables aux normes marocaines (Bilan, CPC (comptes de

View File

@@ -303,7 +303,7 @@ class MrpWorkorder(models.Model):
order.duration = sum(order.time_ids.mapped('duration'))
order.duration_unit = round(order.duration / max(order.qty_produced, 1), 2) # rounding 2 because it is a time
if order.duration_expected:
order.duration_percent = 100 * (order.duration_expected - order.duration) / order.duration_expected
order.duration_percent = max(-2147483648, min(2147483647, 100 * (order.duration_expected - order.duration) / order.duration_expected))
else:
order.duration_percent = 0

View File

@@ -107,6 +107,8 @@ class StockRule(models.Model):
def _get_matching_bom(self, product_id, company_id, values):
if values.get('bom_id', False):
return values['bom_id']
if values.get('orderpoint_id', False) and values['orderpoint_id'].bom_id:
return values['orderpoint_id'].bom_id
return self.env['mrp.bom']._bom_find(
product=product_id, picking_type=self.picking_type_id, bom_type='normal', company_id=company_id.id)

View File

@@ -598,3 +598,45 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
[('product_id', '=', self.wood_product.id)])
self.assertTrue(pickings_component)
self.assertTrue(rr_finish.name in pickings_component.origin)
def test_manufacturing_bom_from_reordering_rules(self):
"""
Check that the manufacturing order is created with the BoM set in the reording rule:
- Create a product with 2 bill of materials,
- Create an orderpoint for this product specifying the 2nd BoM that must be used,
- Check that the MO has been created with the 2nd BoM
"""
manufacturing_route = self.env['stock.rule'].search([
('action', '=', 'manufacture')]).route_id
with Form(self.warehouse) as warehouse:
warehouse.manufacture_steps = 'pbm_sam'
finished_product = self.env['product.product'].create({
'name': 'Product',
'type': 'product',
'route_ids': manufacturing_route,
})
self.env['mrp.bom'].create({
'product_tmpl_id': finished_product.product_tmpl_id.id,
'product_qty': 1,
'product_uom_id': finished_product.uom_id.id,
'type': 'normal',
})
bom_2 = self.env['mrp.bom'].create({
'product_tmpl_id': finished_product.product_tmpl_id.id,
'product_qty': 1,
'product_uom_id': finished_product.uom_id.id,
'type': 'normal',
})
self.env['stock.warehouse.orderpoint'].create({
'name': 'Orderpoint for P1',
'product_id': self.finished_product.id,
'product_min_qty': 1,
'product_max_qty': 1,
'route_id': manufacturing_route.id,
'bom_id': bom_2.id,
})
self.env['procurement.group'].run_scheduler()
mo = self.env['mrp.production'].search([('product_id', '=', self.finished_product.id)])
self.assertEqual(len(mo), 1)
self.assertEqual(mo.product_qty, 1.0)
self.assertEqual(mo.bom_id, bom_2)

View File

@@ -670,8 +670,9 @@ class ProductProduct(models.Model):
# Convert from current user company currency to asked one
# This is right cause a field cannot be in more than one currency
if currency:
company = company or self.env.company
prices[product.id] = product.currency_id._convert(
prices[product.id], currency, product.company_id, fields.Date.today())
prices[product.id], currency, company, fields.Date.today())
return prices