summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-09-24 11:11:49 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-09-24 11:11:49 +0700
commit248fd7cb0c93e60bdfccaf095cdb601a3319b65e (patch)
tree61800ea7ded5d8a231dbaafb9e18ab288e53efbb
parentf38c1291c45beebd9c44939aee1adbf46cdbd7dd (diff)
add several column in sales order and order line
-rwxr-xr-xindoteknik_custom/models/sale_order.py20
-rwxr-xr-xindoteknik_custom/views/sale_order.xml6
2 files changed, 24 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 7366d67a..30ac2058 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -21,6 +21,9 @@ class SaleOrder(models.Model):
have_visit_service = fields.Boolean(string='Have Visit Service', help='To compute is customer get visit service', compute='_compute_have_visit_service')
count_line_product = fields.Float('Count Line Product', compute='compute_count_line_product')
delivery_amount = fields.Float('Delivery Amount', compute='compute_delivery_amount')
+ shipping_cost_covered = fields.Boolean('Shipping Cost Covered', help='Centang jika Shipping Cost ditanggung oleh '
+ 'Indoteknik, jika dicentang akan '
+ 'mempengaruhi margin')
def _compute_have_visit_service(self):
@@ -118,11 +121,24 @@ class SaleOrder(models.Model):
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
item_margin = fields.Float(
- 'Total Margin', compute='compute_item_margin',
+ 'Margin', compute='compute_item_margin',
help="Total Margin in Sales Order Header")
item_percent_margin = fields.Float(
- 'Total Percent Margin', compute='compute_item_margin',
+ '%Margin', compute='compute_item_margin',
help="Total % Margin in Sales Order Header")
+ vendor = fields.Many2one(
+ 'res.partner', string='Vendor', readonly=True,
+ states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
+ required=True, change_default=True, index=True, tracking=1,
+ domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",)
+ vendor = fields.Many2one(
+ 'res.partner', string='Vendor', readonly=True,
+ states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
+ change_default=True, index=True, tracking=1,
+ domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", )
+ purchase_price = fields.Float('Purchase', required=True, digits='Product Price', default=0.0)
+ tax_id = fields.Many2one('account.tax', string='Tax',
+ domain=['|', ('active', '=', False), ('active', '=', True)])
def compute_item_margin(self):
for line in self:
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index b2466b0d..c101fe1b 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -13,9 +13,15 @@
/>
</button>
<field name="payment_term_id" position="after">
+ <field name="shipping_cost_covered"/>
+ </field>
+ <field name="partner_shipping_id" position="after">
<field name="approval_status" />
</field>
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_total']" position="after">
+ <field name="vendor" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}"/>
+ <field name="purchase_price" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}"/>
+ <field name="tax_id" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}"/>
<field name="item_margin" groups="sales_team.group_sale_manager"/>
<field name="item_percent_margin" groups="sales_team.group_sale_manager"/>
</xpath>