Skip to content

Commit

Permalink
[4192][IMP] connector_ebisumart: aware transfer picking scheduled_date (
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKoKoLin1997 authored Jan 11, 2024
1 parent 6dd7712 commit 94c3d85
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion connector_ebisumart/components/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def modifier(self, record, to_attr):
raw_date = record[field]

# If the date is invalid, return None
if raw_date == '0000-00-00 00:00:00':
if raw_date == '0000-00-00 00:00:00' or raw_date is None:
return None

# Convert the string to a naive datetime
Expand Down
8 changes: 5 additions & 3 deletions connector_ebisumart/models/automatic_workflow_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ class AutomaticWorkflowJob(models.Model):
def _do_validate_picking(self, picking):
super()._do_validate_picking(picking)
if picking.sale_id.cancel_in_ebisumart:
self.create_return_picking(picking.sale_id)
return_date = picking.sale_id.ebisumart_cancel_date
self.create_return_picking(picking.sale_id, return_date)
purchase_order = self.env['purchase.order'].search(
[('origin', '=', picking.sale_id.name)]
)
if not purchase_order:
return
self.create_return_picking(purchase_order)
self.create_return_picking(purchase_order, return_date)

def _do_validate_invoice(self, invoice):
super()._do_validate_invoice(invoice)
Expand All @@ -32,7 +33,7 @@ def _do_validate_invoice(self, invoice):
continue
self.create_credit_note(purchase_order, invoice_type="in_invoice")

def create_return_picking(self, order):
def create_return_picking(self, order, return_date):
for picking in order.picking_ids.filtered(lambda r: r.state == 'done'):
# Create the reverse transfer
stock_return_picking = self.env['stock.return.picking']
Expand All @@ -47,6 +48,7 @@ def create_return_picking(self, order):
new_return_picking = self.env['stock.picking'].browse(
return_result['res_id']
)
new_return_picking.write({'scheduled_date': return_date})

# Validate (confirm) the return picking
if new_return_picking.state != 'done':
Expand Down
1 change: 1 addition & 0 deletions connector_ebisumart/models/ebisumart_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SaleOrder(models.Model):
)
cancel_in_ebisumart = fields.Boolean()
ebisumart_send_date = fields.Datetime()
ebisumart_cancel_date = fields.Datetime()

def get_tax_exclusive_price(self, price_inclusive, tax_percent):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SaleOrderImportMapper(Component):
("ORDER_NO", "external_id"),
("ORDER_DISP_NO", "name"),
(normalize_datetime('SEND_DATE'), 'ebisumart_send_date'),
(normalize_datetime('CANCEL_DATE'), 'ebisumart_cancel_date'),
(normalize_datetime('REGIST_DATE'), 'created_at'),
(normalize_datetime('UPDATE_DATE'), 'updated_at'),
]
Expand Down
2 changes: 2 additions & 0 deletions connector_ebisumart/views/sale_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<field name="arch" type="xml">
<field name="confirmation_date" position="after">
<field name="ebisumart_send_date" readonly="1" />
<field name="cancel_in_ebisumart" invisible="1" />
<field name="ebisumart_cancel_date" readonly="1" attrs="{'invisible': [('cancel_in_ebisumart', '=', False)]}"/>
</field>
</field>
</record>
Expand Down

0 comments on commit 94c3d85

Please sign in to comment.