Skip to content

[18.0][ADD] edi_purchase_diapar_oca#7

Open
P-H-Phuc wants to merge 16 commits into18.0from
18.0-mig-edi_purchase_diapar
Open

[18.0][ADD] edi_purchase_diapar_oca#7
P-H-Phuc wants to merge 16 commits into18.0from
18.0-mig-edi_purchase_diapar

Conversation

@P-H-Phuc
Copy link
Copy Markdown
Owner

@P-H-Phuc P-H-Phuc commented Dec 17, 2025

This module was initially part of the Foodcoop set of addons. We're now migrating it to 18.0 and taking this occasion to contribute it to OCA.

@P-H-Phuc P-H-Phuc changed the title [18.0][MIG] edi_purchase_diapar: Migration to 18.0 [18.0][ADD] edi_purchase_diapar Dec 17, 2025
Copy link
Copy Markdown

@nguyenminhchien nguyenminhchien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch from bbb4a17 to b48a236 Compare February 9, 2026 11:41
@P-H-Phuc P-H-Phuc changed the title [18.0][ADD] edi_purchase_diapar [18.0][ADD] edi_purchase_diapar_oca Feb 10, 2026
@P-H-Phuc
Copy link
Copy Markdown
Owner Author

P-H-Phuc commented Feb 10, 2026

CONFIGURATION

I. FS Storage

Go to Settings > Technical > FS Storage

  • Name: Diapar FTP Storage
  • Code: diapar_ftp
  • Protocol: ftp (FTPFileSystem)
  • Options: {"host": "127.0.0.1", "username": "admin", "password": "admin", "port": 5000}

II .EDI Backend Type

Go to EDI > Config > Backend types

  • Name: DIAPAR
  • Code: diapar
  • Name: Diapar

III. EDI Backend

Go to EDI > Config > Backends

  • Name: Diapar
  • EDI Backend type: DIAPAR
  • FS Storage: Diapar FTP Storage
  • Input pending directory: IN/PENDING
  • Input done directory: IN/DONE
  • Input error directory: IN/ERROR
  • Output pending directory: OUT/PENDING
  • Output done directory: OUT/DONE
  • Output error directory: OUT/ERROR

IV. EDI Exchange Template Output

Go to EDI > Config > EDI Exchange Template Output

  • Name: Diapar Output Exchange Template
  • EDI Backend type: Diapar
  • Backend: Diapar
  • Code: diapar.output.exchange.template
  • Output Type: text
  • Generator: Qweb Template
  • Qweb Template: create new template
  • Business params: Vrp Code, Customer Code, Constant File Start / End,...

V. EDI Exchange Type

Go to EDI > Config > Exchange types
1. OUTPUT: PO

  • Name / Code: diapar_out_order
  • Backend / Backend type?: Diapar
  • Direction: Output
  • Enabled for partners: Select partners...
  • Filename pattern: edi.config.system.po_text_file_pattern
  • File ext: C99
  • Encoding: iso-8859-1

2. INPUT: BLE (Despatch Advice)

  • Name / Code: diapar_in_despatch_advice
  • Backend / Backend type: Diapar
  • Direction: Input
  • partner_ids: Select partners...
  • Filename pattern: BLE*
  • File ext: txt
  • Encoding: iso-8859-1
  • Advanced Settings:
components:
    process:
        usage: input.process.diapar.purchase.price
        env_ctx:
            msg_type: 'Purchase Price'
  • INPUT: Purchase Price (CH)
    • Name/Code: diapar_in_purchase_price
    • Backend: Diapar
    • Direction: Input
    • partner_ids: from edi.config.system.supplier_id
    • Filename pattern: CH*
    • File ext: txt
    • Encoding: iso-8859-1
    • Advanced Settings:
components:
    process:
        usage: input.process.diapar.purchase.price
        env_ctx:
            msg_type: 'Purchase Price'

VI. EDI Configuration

Go to EDI > Config > Configurations

  • Name: Diapar Purchase Order
  • Backend: Diapar
  • Exchange Type: diapar_out_order
  • Trigger: On record write
  • Model: Purchase Order
  • EDI Config Do:
if record.state == 'purchase':
  record._edi_send_via_edi(conf.type_id)

VII. Vendor

Open Vendor form > EDI > Purchase > Select EDI Configure Diapar Purchase Order

@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch from b48a236 to aa112f3 Compare February 10, 2026 04:48
Copy link
Copy Markdown

@nguyenminhchien nguyenminhchien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I cannot test the module
  • When creating new product supplierinfo, i faced this error:
Image
  • When creating new PO without supplierinfo, i faced this error:
Image
  • Add unit tests please.
  • Create demo data following your guideline
Image


@api.constrains("product_code")
def _check_product_code(self):
if self.product_code:

This comment was marked as resolved.



class SupplierInfo(models.Model):
_inherit = "product.supplierinfo"

This comment was marked as resolved.

@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch 2 times, most recently from 5337f81 to c8f2c77 Compare March 3, 2026 11:04
@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch 3 times, most recently from f32a10b to 31bba96 Compare March 6, 2026 07:54
@P-H-Phuc P-H-Phuc requested a review from nguyenminhchien March 6, 2026 07:54
cls.normal_supplier = cls.env.ref("base.res_partner_4")
cls.product_4 = cls.env.ref("product.product_product_4")
cls.product_5 = cls.env.ref("product.product_product_5")
cls.supplier_info_5 = cls.env["product.supplierinfo"].create(

This comment was marked as resolved.

updated_values = self._get_updated_quantity_values(
line, edi_exchange_type, picking_order, supplier_info
)
values_list += [Command.create(updated_values)]

This comment was marked as resolved.

str(e),
)

return self.msg_price_updated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's meaningless when always return Price Updated. Supposed that all products were failed but it still returned "Price Updated"!

edi_exchange_type, "supplier_code"
)
product_code = line[pos_from:pos_to]
if product_code in value:

This comment was marked as resolved.

picking_update = self._handle_create_picking_update(exchange_record)
if picking_update:
picking_update.button_update_picking_order()
return self.msg_despatch_processed % picking_update.name.name

This comment was marked as resolved.

nguyenminhchien

This comment was marked as resolved.


partner_is_edi = fields.Boolean(
related="partner_id.is_edi",
string="Partner (Is Edit)",

This comment was marked as resolved.

"code": code,
"origin_code": origin_code,
"quantity": line.product_qty_package,
"quantity": line.product_qty,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a field product_packaging_qty for the package qty. You should add new field to res.partner or somewhere (qty_policy,..) which decide to set the quantity here = line.product_qty or line.product_packaging_qty.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module also depends on purchase_package_qty. A separate module is required for customization. It additionally relies on coop_purchase to update base_price instead of price field.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Qty: product_packaging_qty was added by module "purchase".
  • Price: You can consider to add a glue module to handle it. That new module can put in foodcoop-addons.

@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch from 31bba96 to b47b026 Compare April 14, 2026 10:18
@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch 6 times, most recently from 9a236f9 to d2f7f3c Compare April 15, 2026 09:30
Copy link
Copy Markdown

@nguyenminhchien nguyenminhchien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not create new field to res.partner. Create new glue module in foodcoop-addons to handle the case of qty.

@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch 3 times, most recently from 9b96a3a to 3ba1f2a Compare April 22, 2026 10:25
@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch from 3ba1f2a to 23a95a2 Compare April 23, 2026 11:02
@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch 3 times, most recently from 5b0a4a4 to 8efa08f Compare April 24, 2026 10:11
@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch 3 times, most recently from 279a1cd to 30dbff9 Compare May 4, 2026 10:44
@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch 5 times, most recently from a58cd9b to 07d51fb Compare May 6, 2026 05:08
@P-H-Phuc P-H-Phuc force-pushed the 18.0-mig-edi_purchase_diapar branch from 07d51fb to 619aae0 Compare May 6, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants